![]() |
|
|
|
|
|||||||
| 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 |
| Problem printing the property of xml file via shell script | neeto | Shell Programming and Scripting | 4 | 04-16-2008 10:39 AM |
| Shell script $0 argument | painulyarun | UNIX for Dummies Questions & Answers | 2 | 03-25-2008 04:32 PM |
| Problem when passing argument to a shell script | sumesh.abraham | Shell Programming and Scripting | 9 | 12-13-2006 09:07 AM |
| Argument list too long - Shell error | dad5119 | Shell Programming and Scripting | 8 | 03-03-2006 12:57 PM |
| shell script argument parsing | rmjoe | Shell Programming and Scripting | 1 | 07-28-2005 12:37 PM |
|
|
Submit Tools | LinkBack | Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
printing last argument in shell script
All,
I am having a shell script and i will pass different argument diferent time . Please tell me how can i find the last argument that i passsed each time when i exec the script. Thanks, Arun. |
| Forum Sponsor | ||
|
|
|
#2
|
||||
|
||||
|
I think, you have to redirect the value of argument to file
and then echo(by command cat) it where do you want. |
|
#3
|
||||
|
||||
|
Quote:
'man ksh' yields the following: Code:
Parameters Set by Shell
The following parameters are automatically set by the shell:
# The number of positional parameters in decimal.
|
|
#4
|
||||
|
||||
|
You can do something like this :
Code:
echo "Argument count = $#" if [ $# -gt 0 ] then eval last_arg=\$$# else last_arg='<none>' fi echo "Last argument = $last_arg" Jean-Pierre. |
|
#5
|
|||
|
|||
|
With bash version 3.0 or higher you can use
Code:
${BASH_ARGV[0]}
Quote:
|
|
#6
|
||||
|
||||
|
Code:
echo "$`echo $#`" |
||||
| Google The UNIX and Linux Forums |