Passing variable with *


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Passing variable with *
# 1  
Old 03-28-2012
Passing variable with *

Hi Folks,
I would like to pass a variable with a wild card in an argument. My script works if I don't use a wildcard but fails when I use *. I want to use the script like:
scriptname -F <filename*>
Code:
@ i = 0
while ($i <= ${#argv})
   switch ($argv[$i])
    case -F:
        set j = `echo $i +1 |bc`
        set file = `echo $argv[$j]`
    endsw
@ i++
end

I want my $file = filename*, that is with wild card.
Thanks in advance.
# 2  
Old 03-28-2012
You can try putting the variable in double-quotes " ", but CSH's quoting functionality is extremely perplexing. See csh programming considered harmful.
# 3  
Old 03-28-2012
I already tried the option of using double/single quotes but it doesn't work.

---------- Post updated at 12:12 PM ---------- Previous update was at 11:39 AM ----------

I had to use BASH which allows you to pass variable with wild card provided if you use double quotes.

Thanks for you help.
This User Gave Thanks to dixits For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Passing a variable via ssh, can't quite get it right

Hi Guys n Girls, Below im using a while command to wait for a file on another server then carrying on with the script..... I dont believe the $Sausage1 variable is being passed to the other server so its not finding the file. If i replace the variable with the date then it works as expected. ... (2 Replies)
Discussion started by: twinion
2 Replies

2. UNIX for Advanced & Expert Users

Passing variable as input & storing output in other variable

I have a below syntax its working fine... var12=$(ps -ef | grep apache | awk '{print $2,$4}') Im getting expected output as below: printf "%b\n" "${VAR12}" dell 123 dell 456 dell 457 Now I wrote a while loop.. the output of VAR12 should be passed as input parameters to while loop and results... (5 Replies)
Discussion started by: sam@sam
5 Replies

3. Shell Programming and Scripting

Passing a variable value to an option

Hello, I am new to shell (i.e. linux bash) programming and have the following question: When using this wget command I can download a certain website that needs login information by passing a previously acquired cookie: wget --header='Cookie: SID=ac658ef0876b24ff456' somewebsite.comAs... (5 Replies)
Discussion started by: iggy98
5 Replies

4. Shell Programming and Scripting

Passing dynamic variable within another variable.

I have a small program which needs to pass variable dynamically to form the name of a second variable whose value wil be passed on to a third variable. ***************** Program Start ****************** LOC1=/loc1 PAT1IN=/loc2 PAT2IN=/loc3 if ; then for fpattern in `cat... (5 Replies)
Discussion started by: Cyril Jos
5 Replies

5. Shell Programming and Scripting

Passing variable to awk

Hi, I'm new with this stuff, but I hope you can help me. This is what I'm trying to do: for id in $var; do awk '{if ($1 == $id) print $2}' merg_data.dat > neigh.tmp done I need that for every "id", awk search the first column of the file merg_data.dat which contains "id" and... (3 Replies)
Discussion started by: matteo86
3 Replies

6. Shell Programming and Scripting

Passing a wildcard in a variable

Hi There I am new to scripting and require some assistance please. I am trying to define a variable with a wildcard in a shell script (.ksh) that will be run on AIX 5300-10. The variable I am trying is: FILES=LLA_*.CSVWhen I run the following section of the script: scp... (2 Replies)
Discussion started by: jimbojames
2 Replies

7. Shell Programming and Scripting

Passing Variable in sed

Dear All, I want to print a file. First I tried with this sed '2q;d' filename it worked. But when i put following it is not working x=2; sed '$xq;d' filename Would any one suggest how to pass the variable? (7 Replies)
Discussion started by: saifurshaon
7 Replies

8. Shell Programming and Scripting

passing a variable inside another variable.

Any help would be great. I know this is a dumb way of doing this, but I would like to know if there is a solution doing it this way. I'm very new at this and I'd like to learn more. Thanks! :D:D count=0 while ; do echo "enter your name" read name_$count let count=count+1 done ... (2 Replies)
Discussion started by: reconflux
2 Replies

9. UNIX for Dummies Questions & Answers

passing a variable inside a variable to a function

I would like to know how to pass a variable inside a variable to a function. sample code below -------------- for x in 1 9 do check_null $C$x ##call function to check if the value is null if then echo "line number:$var_cnt,... (2 Replies)
Discussion started by: KingVikram
2 Replies

10. UNIX for Dummies Questions & Answers

Variable passing

Hi, If a script A(Parent) is running and script B(child) is run from script A, will the variables in script A be past to script B? Will the variables exist only for the duration of running the script? Thank you (2 Replies)
Discussion started by: whugo
2 Replies
Login or Register to Ask a Question