Text Manipulation/Replacement

Brian McKee brian.mckee at gmail.com
Tue Sep 23 02:22:50 UTC 2008


>> cat foo.txt | perl -pi -e 's/\n//g'
> This worked...kinda...but it ate all of the new lines, so I have one continuous line.  I need to find all instances of "\n," and replace them with ",".

cat foo.txt | perl -pi -e 's/\n/,/g'  should work.

Why don't you post the complete script so far and maybe we can combine
things in better order?  I usually use vim to mangle text, but if you
need it to be usable by others, a script sounds like the best choice.

Brian




More information about the ubuntu-users mailing list