aboutsummaryrefslogtreecommitdiff
path: root/bin/onl.awk
blob: 89469f3cd729de200721e9037c90624dc361ec61 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Flatten input into one single-space separated line with no unprintable chars

# For each line of input ...
{ 
    # Replace groups of spaces and control characters with one space,
    # implicitly re-splitting the fields
    gsub(/[\a\b\f\n\r\t\v ]+/, " ")

    # Print each field, without a newline; add a leading space if it's not the
    # very first one
    for (i = 1; i <= NF; i++)
        printf (f++) ? OFS "%s" : "%s", $i
}

# Print a newline to close the line
END { print "" }