Globbing happens before your script is run.
After the expansion is done, in your case, your command line looks like:
./script.sh ff file flash2mp3 fold
As you can see, « ff
» becomes the first parameter of your script ( i.e., $1
If you want to avoid this behavior, you have two solutions:
1. Quote « f*
» ( i.e., « 'f*'
» or « "f*"
» ) and not $1
inside your script ;
2. Use the @
parameter ( i.e. « "$@"
» ) instead of $1
inside your script. (preferred)
Also, using ls
(1) in a script is bad.
Unless your intention is only to retrieve filenames in a file then do nothing with the data, tell us what you're actually doing.