Results 1 to 3 of 3
I've tried made it like this:
#! /bin/bash
echo $[$#]
But it seems the outer $ doesn't work, I want the result like this:
./test a f d s g
...
- 08-16-2008 #1Just Joined!
- Join Date
- Sep 2005
- Location
- China
- Posts
- 37
[SOLVED] How can I quote the last argument in the bash script?
I've tried made it like this:
#! /bin/bash
echo $[$#]
But it seems the outer $ doesn't work, I want the result like this:
./test a f d s g
g
How can I make it?
- 08-16-2008 #2Linux Engineer
- Join Date
- Apr 2006
- Location
- Saint Paul, MN, USA / CentOS, Debian, Solaris, SuSE
- Posts
- 1,117
Hi.
I recommend that you look at: http://www.tldp.org/LDP/abs/html/othertypesv.html around the text:
In fact, the guide http://www.tldp.org/LDP/abs/html/index.html is something that you can use to find almost every answer for bash questions ... cheers, drlBracket notation for positional parameters leads to a fairly simple way of referencing the last argument passed to a script on the command line ...Welcome - get the most out of the forum by reading forum basics and guidelines: click here.
90% of questions can be answered by using man pages, Quick Search, Advanced Search, Google search, Wikipedia.
We look forward to helping you with the challenge of the other 10%.
( Mn, 2.6.n, AMD-64 3000+, ASUS A8V Deluxe, 1 GB, SATA + IDE, Matrox G400 AGP )
- 08-17-2008 #3Just Joined!
- Join Date
- Sep 2005
- Location
- China
- Posts
- 37
Ok, I've got it.
just add "eval" at the head.
eval echo ${$#}


