Scripting Snippets

Bits of scripting I use infrequently and always have to lookup!

Looping and reading a line at a time

while read line; do
  echo $line
done < test.txt

Remove annoying .DS_Store files even if directories that have spaces in them

find . -name .DS_Store -exec rm {} \;

Find differences between two directories (with subdirectories), stating if files differ

diff -rq $DIR1 $DIR2

Count files in current and all subdirectories

find . -type f | wc -l

Leave a Reply

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

Security Question * Time limit is exhausted. Please reload the CAPTCHA.