hello,
i have tried to remove blank lines from a file using korn shell script file.. it doesn't seem to work!
i tried sed '/^\s*$/d' infile > outfile but that didn't work
i tried sed 's/ *$//;/^$/d' infile > outfile and that didn't work
i tried sed '/^s./d' infile > outfile and that didn't work
what can i do? this is a huge file and some blank lines might be spaces? or tabs? how can i know?
thank you
Does it have to be sed?
grep -v '^[[:space:]]*$' infile > outfile
You could use a similar regexp in sed of course if you wished...
thank you Annihilannic, that worked beautifully on the command line. Use the same thing inside of a script file?
thank you
Yes. Virtually anything you can do on a command-line will be fine in a script. Just keep in mind that the script may not necessarily be running from the same directory.
sed -e '/^[[:space:]]*$/d' file
Thanks to everyone who helped! much appreciated..