Shell Script Quick Reference

Pass paramter to shell script

  //pass notes.txt 'read.sh notes.sh' it prints 'reading file notes.txt'
  file=${1}
  echo "reading file $file"

Use default value if no parameter is passed to shell script

  //Use notes.txt if no value is passed for $1
  file=${1-notes.txt}
  echo "reading file $file"
comments powered by Disqus