Skip to content

Instantly share code, notes, and snippets.

@qinshulei
Last active August 29, 2015 14:07
Show Gist options
  • Save qinshulei/42596b7ba3d8469e09e3 to your computer and use it in GitHub Desktop.
Save qinshulei/42596b7ba3d8469e09e3 to your computer and use it in GitHub Desktop.
bash-equals-separated
#!/bin/bash
for i in "$@"
do
case $i in
-e=*|--extension=*)
EXTENSION="${i#*=}"
shift
;;
-s=*|--searchpath=*)
SEARCHPATH="${i#*=}"
shift
;;
-l=*|--lib=*)
LIBPATH="${i#*=}"
shift
;;
--default)
DEFAULT=YES
shift
;;
*)
# unknown option
;;
esac
done
echo "FILE EXTENSION = ${EXTENSION}"
echo "SEARCH PATH = ${SEARCHPATH}"
echo "LIBRARY PATH = ${LIBPATH}"
echo "Number files in SEARCH PATH with EXTENSION:" $(ls -1 "${SEARCHPATH}"/*."${EXTENSION}" | wc -l)
if [[ -n $1 ]]; then
echo "Last line of file specified as non-opt/last argument:"
tail -1 $1
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment