For a college assignment I was given a part of the sample files used an if statement to check if a file existed and I found the outcome of this if statement changed when the file name was wrapped in double quotes vs when it was just the file name used and can't find out why.
for elem in "$@ ; do if [ ! -e $elem ] ; then echo 1st $$ > $elem else echo next $$ >> $elem fi done
When there aren't double quotes around $elem
the if statement works correctly and appends the argument
with 1st $$
if it doesn't already exist or next $$
if it does exist. When the double quotes are added (which is how the file appears in the sample from my professor), it always writes 1st $$
regardless of whether the file exists or not but can't understand why this happens.