Created
May 25, 2015 06:20
-
-
Save ephrin/13fb1d62513e0f763312 to your computer and use it in GitHub Desktop.
Straight Bash Space Separated Usage `./myscript.sh -e conf -s /etc -l /usr/lib /etc/hosts ` http://linuxgeeks.ru/bash-2.htm
This file contains hidden or 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 | |
| while [[ $# > 1 ]] | |
| do | |
| key="$1" | |
| case $key in | |
| -e|--extension) | |
| EXTENSION="$2" | |
| shift | |
| ;; | |
| -s|--searchpath) | |
| SEARCHPATH="$2" | |
| shift | |
| ;; | |
| -l|--lib) | |
| LIBPATH="$2" | |
| shift | |
| ;; | |
| --default) | |
| DEFAULT=YES | |
| shift | |
| ;; | |
| *) | |
| # unknown option | |
| ;; | |
| esac | |
| shift | |
| 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