i store the output of ls in a variable FL
$FL=`ls`
$echo $FL
f1.txt f2.txt f3.txt f4.txt f5.txt script.sh script.sh~ test.txt
now if i want to retrive the sub-string "f1.txt" from $FL we were taught that this is what i have to do
$set $FL
$echo $1
f1.txt
and echo $2 would give f2.txt and so on...
now suppose i would like to retrive the sub-string one by using a loop how would i do that...
FL=`ls`
CTR=`ls -1 | wc -l`
j=1
for((j=1;j<=$CTR;j++))
do
set $FL
echo $j
done
but the output comes out as
1
2
3
4
5
6
...
its obvious why...i realise that its simply printing the value in variable j...but how do i make it print it like this
f1.txt
f2.txt
f3.txt
...
for doing that i one should echo $1 first time , echo $2 second time and so on...
but i m all out of ideas of how to do it...
please help...