ls positional parameter


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting ls positional parameter
# 1  
Old 02-13-2008
ls positional parameter

Hi .
I am new to Unix. So i have a tough time.
we are using Korn Shell. I have a scenario where i have three files namely
xxx01,xxx02,xxx03. Now when i write ls xxx*|wc -l output is 3. But then i write `ls $1|wc -l` and pass xxx* as positional parameter (sh yyy.sh xxx*)
output is xxx01. other two files are not read. Why is this happening. Can i use the positional parameters in ls like commands. Please help
# 2  
Old 02-14-2008
What you need is "$*" or "$@" . xxx* gets expanded by the shell before being passed to the script. So $1 is xxx01 which is what you see.
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing parameter to script, and split the parameter

i am passing input parameter 'one_two' to the script , the script output should display the result as below one_1two one_2two one_3two if then echo " Usage : <$0> <DATABASE> " exit 0 else for DB in 1 2 3 do DBname=`$DATABASE | awk -F "_" '{print $1_${DB}_$2}` done fi (5 Replies)
Discussion started by: only4satish
5 Replies

2. Shell Programming and Scripting

Command that takes one parameter and then searches for the passed in parameter

Hi I am looking for a unix command or a small shell script which can takes one parameter and then searches for the passed in the parameter in any or all files under say /home/dev/ Can anyone please help me on this? (3 Replies)
Discussion started by: pankaj80
3 Replies

3. Shell Programming and Scripting

Extracting unknown positional parameter in Bourne shell

I have a variable that contains the number of a positional parameter. There is no way of knowing what number this may be, although it is guaranteed to correspond with a valid parameter. In BASH I could just use ${@} to extract that argument. But in a Bourne shell the best I can come up with is... (3 Replies)
Discussion started by: mij
3 Replies

4. Shell Programming and Scripting

Define Positional Parameter Range Awk

Hello All, I am trying to clean up a poorly looking awk command. I am searching for a way to define a range of positional parameters. I may not be searching for the correct syntax. Example: awk ' /14:3*/ {print $2,$3,$4,$5,$6,$7,$8,$9,$10,$11,$12,$13}' app.log Is it possible to shorten... (4 Replies)
Discussion started by: jaysunn
4 Replies

5. Shell Programming and Scripting

Positional parameter passing

Hi All, When passing parameters to a sheel script, the parameters are referenced by their positions such as $1 for first parameter, $2 for second parameter. these positional values can only have values ranging from $0-$9 (0,1,2,3...9). I have a shell script meant to accept 20 parameters. for... (3 Replies)
Discussion started by: ogologoma
3 Replies

6. UNIX for Dummies Questions & Answers

Positional Parameters

Can someone tell me in more layman's terms what positional parameters are and give a good example? My book again is confusing me. :confused: (1 Reply)
Discussion started by: Straitsfan
1 Replies

7. AIX

ls positional parameter

Hi . I am new to Unix. So i have a tough time. we are using Korn Shell. I have a scenario where i have three files namely xxx01,xxx02,xxx03. Now when i write ls xxx*|wc -l output is 3. But then i write `ls $1|wc -l` and pass xxx* as positional parameter (sh yyy.sh xxx*) output is xxx01. other... (1 Reply)
Discussion started by: vasuarjula
1 Replies

8. Shell Programming and Scripting

how do I make dynamic parameter names? Or get the value of a parameter evaluated twi

Say I write something like the following: var1=1 var2=2 for int in 1 2 do echo "\$var$int" done I want the output to be: 1 2 Instead I get something like: $var1 $var2 (2 Replies)
Discussion started by: Awanka
2 Replies

9. Shell Programming and Scripting

positional grep

Hi All, I am using positional grep. when i am passing pattern as parameter it is not working where as for hardcoded value it is working. Does any body has any idea ? e.g. export Name=1234 grep -e '^.\{15\}$Name' FileName {result no record found} grep -e '^.\{15\}1234' FileName correct... (1 Reply)
Discussion started by: Manish Jha
1 Replies

10. UNIX for Dummies Questions & Answers

Positional Parameters

Hello, I am using the Bourne shell. I am trying to understand the concept of positional parameters. I do understand that positional parameters: 1. Are initialized by shell 2. Have a max of 9 parameters ($1 to $9) 3. Have no limit on the number of arguments 4. Can be rearranged... (15 Replies)
Discussion started by: ericelysia
15 Replies
Login or Register to Ask a Question