Many time we face situations where we have many empty lines in a file or script. Then how can we delete only those empty lines & make the file compact?
I tried following steps & they worked like charm.
for deleting all empty lines from the file input.txt, run the following command:
sed command
sed ‘/^$/d’ input.txt > output.txt
OR
sed -i ‘/^$/d’ input.txt
awk command
awk ‘NF > 0’ input.txt > output.txt