diff options
Diffstat (limited to 'bin/onl.awk')
-rw-r--r-- | bin/onl.awk | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/bin/onl.awk b/bin/onl.awk new file mode 100644 index 00000000..140fb64c --- /dev/null +++ b/bin/onl.awk @@ -0,0 +1,28 @@ +# Flatten input into one single-space separated line with no unprintable chars + +# For each not-all-spaces line: +{ + # Strip unprintable chars + gsub(/[^[:print:]]/, "") + + # All horizontal whitespace groups to one space + gsub(/[ \t]+/, " ") + + # No leading or trailing space + sub(/^ /, "") + sub(/ $/, "") + + # If there's nothing left, go on to the next line + if (!length) + next + + # If this isn't the first line, add a leading space + if (NR > 1) + printf " " + + # Print the content without a newline + printf "%s", $0 +} + +# Print a newline to close the line +END { printf "\n" } |