i am trying to print all parameters in bash script "one by one".
fro example i want to run:
./myscript hello all friends
and see below result:
hello
all
friends.
i wrote below code:
#!/bin/bash
li=$@
for(( j=0;j<$#;j++));
do
echo ${li[$j]}
done
bug when i run my code it prints all of argument at once:
hello all friends
i know i can do that by changing the for structure to below format:
#!/bin/bash
li=$@
for j in $li;
do
echo $j
done
but i didn't want to change the code such as above.
please help me.
thank you in advance.