Delete empty lines in a file
Some times there are some empty lines which we feel are redundant in the file and want to remove them.Below is the command in unix to do that.sed -i '/^$/d' your_fileBut there is also another way to do this:
grep . your_file > dest_fileIn perl also we can acheive this as below:
perl -pi -e 's/^$//g' your_filethe above mentioned perl and sed solutions will do an inplace replacement in the file
If in case the lines have some spaces then:
perl -pi -e 's/^\s*$//g' your_file
nice... but take note the '-i' in sed is not posix compliant!?
ReplyDelete