remove blank lines from text file

sed '/^$/d' /path/to/input/file.txt > output.txt
grep -v '^$' /path/to/input/file.txt > output.txt
#!/bin/bash
files="/path/to/input/files/*.txt"
for i in $files
do
  sed '/^$/d' $i > $i.out
  mv  $i.out $i
done
#!/bin/bash
files="/path/to/input/files/*.txt"
for i in $files
do
  sed '/^ *$/d' $i > $i.out
  mv $i.out $i
done

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.