Bash Tidbits

Arguments

echo "argc = ${#*}"
echo "argv = ${*}"

Template for find files and process each file

find . -iname '*.txt' -type f | while read fname; do
  echo "Reading from $fname. Writing to `basename ${fname%.*}`.bin"
  base64 -D "${fname}" > "${fname%.*}.bin"
done

Template for convert .png to .jpg

if [ ! -d processed ]; then mkdir -p processed; fi &&
  for f in ./*.png; do
    ffmpeg -i $f -q:v 10 processed/$f
  done