I am trying the following script for listing the archived files in my current directory.
#!bin/sh
for file in *.{zip,jar}
do
echo $file
done
which gives the output:
*.{zip,jar}
Why isn't shell expanding the braces?
I was wondering what's the need to put executable commands inside a .sh
file to make a single script, since I can do the same by putting the commands inside a .txt
file and making it executable using chmod
.
I'm assuming this can be done with any of the file extensions. So, I am quite confused about the need for .sh
extension. Any help would be much appreciated.