and just to explain why your sed approach won't work ... its not possible to strip newlines using sed like that, since sed operates on one line at a time, there isn't actually any newline character in each line for it to replace.
you can make sed do what you want in a slightly more convoluted way:
Code:
sed ':a;N;$!ba;s/\n//g' somefile
:a create a label to branch back to later
N read in the next line and add it to the pattern space
$!ba for every line except the last, branch back to the start of our expression (ie. keep on reading in subsequent lines)
s/\n//g on the last line, remove all newlines from pattern space (and print the result)
Code:
cat somefile | tr -d '\n'
is almost an equivalent, except that you don't get a final newline this way
Bookmarks