Operating System - HP-UX
1834962 Members
1757 Online
110071 Solutions
New Discussion

What is the meaning of @ itno a script???

 
SOLVED
Go to solution
Manuales
Super Advisor

What is the meaning of @ itno a script???

Sorry ..
into a script, what is the meaning of "@" as folows:

umask $@

thanks ...
Manuale.s
4 REPLIES 4
James R. Ferguson
Acclaimed Contributor
Solution

Re: What is the meaning of @ itno a script???

Hi Manuales:

In a shell script, $@ represents the (positional) arguments passwd to the script. For instance:

# cat my.sh
echo $@

# ./my.sh abc
abc

# ./my.sh abc def
abc def

Hence in the case you show, the assumption is that your script is to receive the octal umask value as an argument to set 'umask'.

Regards!

...JRF...
Jeff Schussele
Honored Contributor

Re: What is the meaning of @ itno a script???

Hi Manuale,

$@ is a positional parameter that provides a list of all arguments.

So does $*, BUT the key is that $@ provides a list of strings whereas $# provides *one* long string containing all arguments.

HTH,
Jeff
PERSEVERANCE -- Remember, whatever does not kill you only makes you stronger!
James R. Ferguson
Acclaimed Contributor

Re: What is the meaning of @ itno a script???

Hi (again):

$# returns the decimal number of arguments passed.

$* is like $@ unless you double quote $* like:

"$*" in which case each positional parameter (argument) acts like you wrote:

$1${IFS}$2${IFS}...

...where ${IFS} is the current Inter Field Seperator.

Pass various arguments (one or more) to this script to see the differences:

# cat my.sh
#!/usr/bin/sh
IFS=":"
echo $@
echo $*
echo "$@"
echo "$*"

# ./my.sh a b c
# ./my.sh "a b c"

Regards!

...JRF...
Manuales
Super Advisor

Re: What is the meaning of @ itno a script???

Thanks my friends !!!

:0)

Manuales.