Oct 22, 2013, 2:25 PM
Post #14 of 16
I do not really know what the OP really wants, but if, as I understand it, the OP wants to remove blank lines from a file, you haven't really done that. Your Perl one-liner is creating a new file with empty lines dropped, just as the (incomplete) code snippet I posted was doing. Now the OP says that she or he wants something else. I presume that she or he probably wants to modify the original file, not just create a new file. If such is the case, it is only a small modification (adding the -i option) to the one-liner you suggested, or possibly using another a one-liner based on my proposal:
(Replacing single quote with double quotes under Windows or VMS.)
perl -i.bak -ne 'print unless /^\s*$/;' filename.txt
Now, since we don't understand the OP's real intents, we might be wasting our time and I do not intend to intervene anymore on this thread so long as these intents have not been clarified by the OP.