0

Hi All,

I want to pass few dynamic arguments to shell script. The number of arguments differ each time I call the script.

I want to print the arguments using the for loop as below. But not working out.

for (( i=1; i<=$#; i++ ))
do
echo $"($i)"
done

/bin/sh test.sh arg1 arg2 arg3

Any one please help.

2
Contributors
2
Replies
3
Views
5 Years
Discussion Span
Last Post by laalesh
0

Try the following:

for i in $*; do
    echo ${i}
done

The $* represents the set of arguments to the script.

0

Try the following:

for i in $*; do
    echo ${i}
done

The $* represents the set of arguments to the script.

its working, thanks.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.