Feeds:
Posts
Comments

Archive for the ‘Bash Scripting’ Category

Shoutout to http://www.digitalpeer.com/id/parsing for this easy way of parsing commandline args in bash:

for i in $*
do
	case $i in
    	-p=*|--prefix=*)
		PREFIX=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
		;;
    	--searchpath=*)
		SEARCHPATH=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
		;;
    	--lib=*)
		DIR=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
		;;
    	--default)
		DEFAULT=YES
		;;
    	*)
                # unknown option
		;;
  	esac
done
Advertisements

Read Full Post »