![]() |
|
|
|
|
|||||||
| Forums | Portal | Register | Forum Rules | FAQ | Contribute | Members List | Arcade | Search | Today's Posts | Mark Forums Read |
| Shell Programming and Scripting Post questions about KSH, CSH, SH, BASH, PERL, PHP, SED, AWK and OTHER shell scripts here. |
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| diff between tcsh and csh -f | mahendrakamath | UNIX for Dummies Questions & Answers | 2 | 11-12-2007 04:19 AM |
| diff | tungaw2004 | UNIX for Dummies Questions & Answers | 3 | 04-25-2007 07:54 AM |
| diff command | gilead29 | UNIX for Dummies Questions & Answers | 7 | 03-09-2004 06:12 PM |
| diff 2 files; output diff's to 3rd file | blt123 | Shell Programming and Scripting | 2 | 05-28-2002 08:29 AM |
| diff and ed? | Brototype | UNIX for Dummies Questions & Answers | 2 | 10-29-2001 11:30 AM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Diff b/w $@ and $#
Hello,
Pls explain the difference between $# and $@, and how its used in shell scripting . Thanks in advance |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
In short, RTFM.
Under Special Parameters in man sh Code:
@ Expands to the positional parameters, starting from one. When
the expansion occurs within double quotes, each parameter
expands to a separate word. That is, "$@" is equivalent to "$1"
"$2" ... When there are no positional parameters, "$@" and $@
expand to nothing (i.e., they are removed).
# Expands to the number of positional parameters in decimal.
|
|
#3
|
|||
|
|||
|
Thanks for the info, but its not clear to me can you explain me via an example......
|
|
#4
|
||||
|
||||
|
An example to help you understand better.
$# - Will give you the number of arguments passed to the script $@ - Will list all the arguments passed Code:
/export/home/test/mons/UnixForum>cat test.sh #!/bin/ksh print "The number of arguments passed to this shell script is " $# print "The arguments passed are as follows" print "$@" Code:
/export/home/test/mons/UnixForum>test.sh hai welcome to unixforum .com The number of arguments passed to this shell script is 5 The arguments passed are as follows hai welcome to unixforum .com |
|
#5
|
|||
|
|||
|
Thanks for the expalantion ......
|
|||
| Google The UNIX and Linux Forums |