ProgrammingThis forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.
Notices
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
hii
i m new to shell scripting and i have a situation which i dont even know if is possible..
suppose i have a variable ... can i expand it to use to make another variable .. i suppsoe this shud be possible
for eg i m tryin to reverse the arguments supplied
#!/bin/bash
echo number of arguments are $#
a=1
while `test $a -le $#`
do
echo ${$a}
a=`expr $a + 1`
done
my problem is in echo line ... i m trying hit n trial to expand $a to a numeric ... and then refrencing the argument as we normally do.. like $1 , $2 and so on
so my question is can i use 2 $ sign ... obviously inner $ shud be expanded to its value ..
i wanna refer to $1 by assigning $a to another $ something like
$$a
where $a shud expand to some integer ... and $<integer> shud be my argument ..
plzz write back .. i m certainly new in scripting ...
thnks
i am no beginner at shell scripting, but i really not clear what you are trying to do. maybe you can explain it a little more? sorry i'm sure others will agree. although its good that you are interesting in this...
kooool Hko
hurray it worked ....please give me a link to some good tutorial on shell script or some book which i can get from college library ..which explains such interesting stuffs
sorry satinet ... but i really write messed up english .. i have been pointed out a lot mant times of LQ .. i will try to improve !! satinet plzz suggest some good book or link to shell scripting
thnk u guys ... i will come back with other silly doubts
thnks again
kooool Hko
hurray it worked ....please give me a link to some good tutorial on shell script or some book which i can get from college library ..which explains such interesting stuffs
sorry satinet ... but i really write messed up english .. i have been pointed out a lot mant times on LQ .. i will try to improve !! satinet plzz suggest some good book or link to shell scripting
thnk u guys ... i will come back with other silly doubts
thnks again
and yehh hko .. wot does shift (after while) do in this script ..by the way we had to print in reverse .. n this script print in the same order as supplied .. i tried to change
#!/bin/bash
echo Number of arguments = $#
echo ${!#}
while shift ; do
echo ${!#}
done
output : last argument
then i tried ...
#!/bin/bash
echo Number of arguments = $#
echo ${!#}
while shift -1 ; do
echo ${!#}
done
output : wu , syntax error
can u give me link to some good book or tutorial .. or refer some good book? i really need it .. i m willin to spend time
thnks in advance
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.