perl -0 -e '$_=<>;s/^\n+//;s/\n+$/\n/;print;' < infile > outfile
Tim
1. Strip blank lines from a .txt file
I have a text file that can contain a large amount of data.
However after using the sort command, I am left with numerous blank
lines. Does anyone know how these could be stripped?
The file is in the format
eggs
baccon
saugage
tomatos
blackpudding
mushrooms
..etc
Thanks
Mick
2. add tape
3. vi: convert double blank lines to single blank lines???
4. Apache's mod_action problem
5. multiple blank lines -> one blank line
7. stripping trailing blank lines
8. XFree86 2.1 and Mach32 (Uploaded)
9. vi: convert double blank lines to single blank lines???
10. skipping empty lines at the top/bottom
11. HELP: How do I read a file line-by-line without getting spaces stripped?
13. Put file lines in an array: how keep line blanks in the string?