Use tr '\n' ' ' to translate all newlines to spaces:
$ grep pattern file | tr '\n' ' '
Note: grep reads files, cat merges files. Not cat file | grep cat file | grep !
Edit:
tr can only handle single character translations. You can use awk to change the output record separator, for example:
$ grep pattern file | awk '{print}' ORS='" '
This will change:
one two three
at
one" two" three"
Chris Seymour Mar 22 '13 at 21:31 2013-03-22 21:31
source share