I found some code to parse command line arguments (is there an easier way? sed always seems so complicated...)
#!/bin/bash
for i in $*
do
case $i in
--files=*)
FILES=`echo $i | sed 's/[-a-zA-Z0-9]*=//'`
;;
--default)
DEFAULT=YES
;;
*)
# unknown option
;;
esac
done
echo $FILES
echo "File 0:"
echo ${FILES[0]}
My question is, how do I loop through the filenames in FILES if I pass multiple files, ie
./Example.sh --files=*.txt
My example above (trying to access it like an array does not split the string at " ", so FILES[0] is the entire FILES.
Any ideas?
Thanks,
Dave