Created
October 22, 2014 07:03
-
-
Save qinshulei/5ff2f4f78f46c9eb3914 to your computer and use it in GitHub Desktop.
bash-space-separated
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
#usage: ./myscript.sh -e conf -s /etc -l /usr/lib /etc/hosts | |
while [[ $# > 1 ]] | |
do | |
key="$1" | |
shift | |
case $key in | |
-e|--extension) | |
EXTENSION="$1" | |
shift | |
;; | |
-s|--searchpath) | |
SEARCHPATH="$1" | |
shift | |
;; | |
-l|--lib) | |
LIBPATH="$1" | |
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