Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Shell Programming 1

Status
Not open for further replies.

badhri

Programmer
Apr 8, 2001
56
US
Hi All,
The Unix shell script(sh) accepts only 9 variables passed from command line. How dod I pass more than 9 variables to the Shell Script.

Thanx,
Badhri...
 
Hi,

the shell passes more than just 9 parameters to your script, there is a limitation in length however. I'm not quite sure about the actual value of today's shells, in former time 8 kB have been a common value. Check for your implementation.

Within the script you can access the parameter 10 and above via
Code:
shift
, as usual: ask the
Code:
man sh
..

ciao, mbr
 
Bourne positional parameters are 1-9 AND Korn positional parameters go higher
using ${parameter} such as 10 would be ${10} and 11 would be ${11} etc....
 
if using a plain old shell script, to access from the 10th
argument up, you must use shift. For instance, to print
the first 3 lines of every file passed, with a litte
header:

while test $# -gt 0; do
echo "==== $1 ===="
sed 3q "$1"
shift
done

also, the "for" construct with no list, runs through
all passed arguments. For example, the above could
have been written as:

for file
do
echo "==== $file ===="
sed 3q "$file"
done

cya

--
pkiller

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top