Perl one-liner to remove from a text file all lines that contain only whitespace.
Other Ways To Do It (mostly not one-liners) can be found at the thread "How do I remove blank lines from text files?".
Hmmm... personally, I like Ovid's example below better than mine. It *does* seem more directly recognizable.
perl -i.bak -ne 'print unless /^\s+$/' file.txt
|
---|
Replies are listed 'Best First'. | |
---|---|
(Ovid) Re: One-liner removes whitespace-only lines from text file
by Ovid (Cardinal) on Dec 19, 2001 at 02:32 UTC | |
Re: One-liner removes whitespace-only lines from text file
by FoxtrotUniform (Prior) on Dec 19, 2001 at 02:21 UTC | |
Re: One-liner removes whitespace-only lines from text file
by jmcnamara (Monsignor) on Dec 19, 2001 at 14:00 UTC | |
by chip (Curate) on Dec 19, 2001 at 14:39 UTC |
Back to
Cool Uses for Perl