Last Updated: February 25, 2016
·
752
· stuartpb

Separate a bash script's arguments into options and targets

To get all the arguments that don't start with a hyphen (targets), use:

${@##-*}

To get all the arguments that do start with a hyphen (options), use:

${@##[^\-]*}