unix shell variable $@


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting unix shell variable $@
# 1  
Old 12-26-2008
unix shell variable $@

Hi All,
I have to debug a unix script file prepared originally by another person.
The script file uses the $@ variable which i guess is a standard Unix variable.

The command is something like this:
Java_PATH=<JAVA_PATH>

<JAVA_PATH>/bin/java com.ibm.ws.bootstrap.WSLauncher com.ibm.ws.webservices.tools.WSDL2Java "$@"

i need to know what does $@ signify?
# 2  
Old 12-26-2008
for bash:

"$@" mean all arguments to current script
That is, "$@" is equivalent to "$1" "$2" ...

#!/bin/bash
echo "All args: $@"
echo "First arg: $1"
echo "Second arg: $2"

-----
$ script.sh 1 2 3 4

All args: 1 2 3 4
First arg: 1
Second arg: 2

man bash
/^\ +\@

Last edited by drugplant; 12-26-2008 at 06:16 PM.. Reason: precise
# 3  
Old 12-26-2008
Thanks

Hi Drugplant,

Thanks for replying.
That explains the script.
# 4  
Old 12-26-2008
Quote:
Originally Posted by drugplant
for bash:

"$@" mean all arguments to current script
That is, "$@" is equivalent to "$1" "$2" ...

But note that $@ is the same as $*; it must be quoted for it to be different.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. UNIX for Beginners Questions & Answers

How can I assign awk's variable to shell script's variable?

I have the following script, and I want to assign the output ($10 and $5) from awk to N and L: grdinfo data.grd | awk '{print $10,$5}'| read N L output from gridinfo data.grd is: data.grd 50 100 41 82 -2796 6944 0.016 0.016 3001 2461. where N and L is suppose to be 3001 and 100. I use... (8 Replies)
Discussion started by: geomarine
8 Replies

2. Shell Programming and Scripting

How to read a two files, line by line in UNIX script and how to assign shell variable to awk ..?

Input are file and file1 file contains store.bal product.bal category.bal admin.bal file1 contains flip.store.bal ::FFFF:BADC:CD28,::FFFF:558E:11C5,6,8,2,1,::FFFF:81C8:CA8B,::FFFF:BADC:CD28,1,0,0,0,::FFFF:81C8:11C5,2,1,0,0,::FFFF:81DC:3111,1,0,1,0 store.bal.... (2 Replies)
Discussion started by: veeruasu
2 Replies

3. Shell Programming and Scripting

[SHELL: /bin/sh] For loop using variable variable names

Simple enough problem I think, I just can't seem to get it right. The below doesn't work as intended, it's just a function defined in a much larger script: CheckValues() { for field in \ Group_ID \ Group_Title \ Rule_ID \ Rule_Severity \ ... (2 Replies)
Discussion started by: Vryali
2 Replies

4. Shell Programming and Scripting

how to store output into variable-in unix shell scripting

Hi, Output of "ps -o etime,time,pcpu,pmem,fname -C sbd-java" command is - Elapsed Time %cpu %MEM COMMAND 02:14:03 00:03:28 2.5 6.3 sbd-java Can anyone tell me, how to store the the value 2.5 in a variable? When I say echo $X where x is a variable then... (4 Replies)
Discussion started by: pspriyanka
4 Replies

5. Shell Programming and Scripting

Not able to store command inside a shell variable, and run the variable

Hi, I am trying to do the following thing var='date' $var Above command substitutes date for and in turn runs the date command and i am getting the todays date value. I am trying to do the same thing as following, but facing some problems, unique_host_pro="sed -e ' /#/d'... (3 Replies)
Discussion started by: gvinayagam
3 Replies

6. Shell Programming and Scripting

assign awk's variable to shell script's variable?

Dear All, we have a command output which looks like : Total 200 queues in 30000 Kbytes and we're going to get "200" and "30000" for further process. currently, i'm using : numA=echo $OUTPUT | awk '{print $2}' numB=echo $OUTPUT | awk '{print $5}' my question is : can I use just one... (4 Replies)
Discussion started by: tiger2000
4 Replies

7. Shell Programming and Scripting

what is the maximum length of a unix shell variable which can be can passed to plsql

what is the maximum length of a unix shell variable which can be can passed to plsql variable:( (1 Reply)
Discussion started by: alokjyotibal
1 Replies

8. Shell Programming and Scripting

Enviornment Variable in B shell (I call it nested variable)

#!/bin/sh APP_ROOT_MODE1=/opt/app1.0 APP_ROOT_MODE2=/opt/app2.0 APP_ROOT=${APP_ROOT_${APP_MODE}} # enviornment variable APP_MODE will be exported in the terminal where # we run the applciation, its value is string - MODE1 or MODE2 # My intension is: # when export APP_MODE=MODE1... (4 Replies)
Discussion started by: princelinux
4 Replies

9. UNIX for Dummies Questions & Answers

select count(*) in sqlplus into variable unix shell

Need to select count(*) from table to check for zero result in unix script (2 Replies)
Discussion started by: struggle
2 Replies

10. UNIX for Dummies Questions & Answers

Problem in incrementin a variable in UNIX shell script

I have a simple query If we have BATCH= 081675 and incremnting it by one as BATCH=`expr ${BATCH} + 000001`; We can't get BATCH = 081676 but gets BATCH = 81676 Can anyone tell why i am getting this value and not the rquired one and how i could get the required one? (1 Reply)
Discussion started by: communicator
1 Replies
Login or Register to Ask a Question