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

# For each line of input ...
{ 
    # Strip out non-printable characters and rebuild the fields
    gsub(/[^[:print:]]+/, "")

    # 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++) ? " %s" : "%s", $i
}

# Print a newline to close the line
END { printf "\n" }