sed: replacing multiple empty lines with one
As simple as:
sed -e '/^$/N;/^\n$/D' <file>
As simple as:
sed -e '/^$/N;/^\n$/D' <file>
If you need to pass some variable from bash to sed use double quotes:
sed -i "s/$var/replace/g" "$file"
Easy.
To remove empty lines run:
sed '/^$/d' /home/dandelion/itsfile.txt
To remove lines matching the pattern:
sed '/patter/d' /home/dandelion/itsfile.txt
Add -i option to remove in a file itself, instead of printing the output to stdout.