Hi All,
I have a brain teaser. I am attempting to loop through a number of positional parameters but keep getting caught in an infinite loop.
The input is : $ script_name (p_par_1) ...(p_par_n)
The script I have:
#!/usr/bin/ksh
x=1
while [ -n $`$x` ] ; do #do while x is not null
echo $`$x` #print the value of $1, $2, etc.
x=x+1 # increment x to evaluate next
done #script should end when pos_vars run out or [-n $n]
Problem is that it treats $`$x` as a literal and never evaluates it as $1, $2 , etc as I want it to. I think I am close and that it is something with the quotes or something easy.
Ravioli
I have a brain teaser. I am attempting to loop through a number of positional parameters but keep getting caught in an infinite loop.
The input is : $ script_name (p_par_1) ...(p_par_n)
The script I have:
#!/usr/bin/ksh
x=1
while [ -n $`$x` ] ; do #do while x is not null
echo $`$x` #print the value of $1, $2, etc.
x=x+1 # increment x to evaluate next
done #script should end when pos_vars run out or [-n $n]
Problem is that it treats $`$x` as a literal and never evaluates it as $1, $2 , etc as I want it to. I think I am close and that it is something with the quotes or something easy.
Ravioli