Linux Tip: Removing blank lines from a text file

Method 1: Using grep

$ grep -v '^$' infile.txt > outfile.txt

Method 2: Using sed

$ sed '/^$/d' infile.txt > outfile.txt

To remove blank lines from multiple files a script like the one below can be used

for f in $files
  sed '/^$/d' $f > $f.tmp
  mv  $f.tmp $f

Linux Tip: Recursively count files in a folder

Finding number of files in a folder

# find . -type f | wc -l

Finding number of subfolders in a folder

# find . -type d | wc -l

Finding number of subfolders only in the current folder

# find . -maxdepth 1 -type d | wc -l