I need to execute a command for a list of files that convert them from one format to another, say:
conv -option MYOPTION file1 > file1.output
However, I have a list of files in a folder, say:
file1, file2, …, fileN
I need a script that runs such command for each and every file, something like:
script.sh MYOPTION *.TXT
I did some research and found something like:
for f in *; do
echo "$f"
done
Now the problems are:
- How do I get the "list of files", in my example,
*.TXT
, into the script so it's mapped to the list of files? (ie. no hardcoded*
in the script, it should work also if I only specify one single file) - How do I invoke system command in a script? Something like
conv -option $1
?
Thanks!