manipulate a Unix file (stream) to lines

August 12, 2011 at 07:47:30
Specs: Unix
I have a file that is a stream of characters, whenever the character ~ (tilda) is found, I need to replace it with ~NL (tilda New_Line) so I can get a file of text lines for further processing. Please help.
Shlomo

See More: manipulate a Unix file (stream) to lines

Report •

#1
August 12, 2011 at 11:43:22
What version of Unix are you using? By definition, if your file is a stream of characters, the file is one long line. The older legacy Unix (i.e. Solaris, HP-UX, AIX, etc ) tools will fail with a "line too long error". The GNU Linux tools generally don't have this problem - at least I have never seen it:

This command has the best chance of working:

perl -wpl -e 's/~/~\n/g;' file.txt > newfile.txt



Report •

#2
August 15, 2011 at 05:34:05
Thank you very much Nails; this does the job beautifully.

Report •
Related Solutions


Ask Question