Shell - useful code

Shell commands

Operations on arguments

Checking if an argument has been defined:

if [ "$1" == "" ]; then
    # No argument found
else
    # At least one argument
fi

Parsing from the 2nd argument:

if [ "$1" == "clean" ]; then
    clean=1
    args="${@:2}"
else
    clean=0
    args="$@"
fi
Share Comments
comments powered by Disqus