I'm trying to make a script that's supposed to tell me which argument stars with a dash. I looked at In Bash, how can I check if a string begins with some value?, but the accepted answer didn't work.
Here is the script:
for var in "$@"
do
echo "$var"
if [[ $var == -* ]]
then
echo "$var starts with dash"
fi
done
When I run it I just get this:
~$ ./dash_test.sh -dash no_dash --two -one
-dash
no_dash
--two
-one
That if [[ $var == -* ]]
doesn't appear to work, which is what was suggested in that question I linked.