Script loop question

Markus Schönhaber ubuntu-users at list-post.mks-mail.de
Thu Nov 12 09:13:19 UTC 2009


Oliver Marshall:

> I have a script that takes an argument (a file name) and performs
> actions on that file. I want to mod the script so that i can pass, as
> arguments, multiple filenames and have the script perform the same
> set of commands on each file in turn, like this;
> 
> ./filename.sh file1 file2 file3
> 
> etc.
> 
> I guess it's bringing the two parts of the loop and the arguments
> together to loop through each argument in turn, but that's where I
> get stuck.

for f in "$@"; do
  echo $f
done

-- 
Regards
  mks





More information about the ubuntu-users mailing list