How to get / echo positional parameters index

anneranch

Member
I have this working and simple code to echo positional parameters VALUES

for i
do
echo "Argument = $i "
done

Here is the actual output from the scrip

Argument = --atleast-pkgconfig-version
Argument = 0.9.0



It does the job, but ...
I have been trying to figure out how to ADD an index to the echo output.

This does not work

cnt=1
for i
do
echo "Argument $cnt = $i "
((cnt++))
done

The current code does the job, the index would be just icing on the cake - like this:

Argument #1 = --atleast-pkgconfig-version
Argument #2 = 0.9.0


Any ideas ?
 

Members online


Latest posts

Top