I'm scripting a sequence of commands I used to enter by hand. The rough outline goes something like this
$ echo ${FILENAME_ARGS} | some | big | pipeline | sort -options | etc >temp
$ gs -OptionsThatNeverChange `cat temp`
Basically, the only thing that changes between runs are the options passed to sort and the files contained in FILENAME_ARGS.
What I want to do is be able to type something like
$ do-thing -some -options *.pdf
and have all of the -whatever
go to the options for sort, while all of the *.pdf
go into FILENAME_ARGS. To do this I need a way to pick out all of the things that start with a -
from $@
. Is there some simple way to pull options out of the arguments passed to a shell script?