I want to loop through the arguments in a bash script (ie if I call
./MyScript *.txt
in a folder with files: a.txt b.txt c.txt
I want to operate on each of those files.)
I know the arguments are $1, $2, etc - but how do you construct a variable name like that - ie
See what I'm trying to do? Is this how this should be approached?Code:#!/bin/bash echo number of arguments is $# for i in `seq 1 $#`; do echo argument ${i}: `$i` #this last part is the problem done;
Thanks,
Dave


Reply With Quote
