If I run the command cat file | grep pattern, I get many lines of output. How do you concatenate all lines into one line, effectively replacing each \"\\n
cat file | grep pattern
\"\\n
Here is another simple method using awk:
awk
# cat > file.txt a b c # cat file.txt | awk '{ printf("%s ", $0) }' a b c
Also, if your file has columns, this gives an easy way to concatenate only certain columns:
# cat > cols.txt a b c d e f # cat cols.txt | awk '{ printf("%s ", $2) }' b e