Remove Newlines from Command Line Output

July 2012

You can remove newlines from command line tools the return a single line of text by piping it to:

tr -d '\n'

For example:

echo "this is a test" | tr -d '\n'

Alternative with awk

This is a more verbose way to do it with awk

echo "this is a test" | awk '{ printf "%s", $0 }'
end of line