C Shell - foreach - No Match error


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting C Shell - foreach - No Match error
# 1  
Old 04-26-2009
C Shell - foreach - No Match error

Hi All,

I am facing 'No Match' problem with foreach loop in C shell script.

Initially I tried following grep command showing results properly as shown at the end of the Thread. But foreach command is throwing the error 'No match'.

grep -n Inserted audit_file
foreach insertstr (`grep -n Inserted audit_file`)
echo "$insertstr"

Temporarily I have copied output of the grep command into a temp file. Now the foreach command has moved a little bit but thrwoing follwoing error

50:00000050 2009/04/: No such file or directory

foreach Insertstr ("`cat temp.txt`")


00000050 2009/04/24 02:35:16.520 OPGS 529 INFO BATR Inserted [35] complete messages
00000079 2009/04/24 03:35:19.128 OPGS 529 INFO BATR Inserted [64] complete messages
00000022 2009/04/24 04:35:25.541 OPGS 529 INFO BATR Inserted [7] complete messages
00000017 2009/04/24 16:00:06.058 OPGS 529 INFO BATR Inserted [2] complete messages
00003480 2009/04/24 16:20:47.631 OPGS 529 INFO BATR Inserted [3465] complete messages


Thanks
-Durga
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Foreach alternative - C shell

Hi all I wrote a foreach loop in c-shell: foreach file (/.../fileNames*) ... end The problem is that if there aren't matching files in the directory I'm getting a "foreach: No match". How can I rewrite it so the script will just skip the loop if there aren't any matching files? ... (4 Replies)
Discussion started by: Somename
4 Replies

2. UNIX for Dummies Questions & Answers

Shell script foreach help

I am writing a shell script to uncompress files in a directory, then call a Perl script to search the files for given terms, store those terms in a different output file , and compress the output. I get a syntax error with my use of foreach. Below is my script. #!/bin/csh -fxv if (!... (2 Replies)
Discussion started by: dgrayman
2 Replies

3. Shell Programming and Scripting

Foreach statement error in cshell

Hi, while executing the following c-shell script i got the error "Couldn't find an 'end' to close a 'foreach' statement" can't find the mistake ...plz help.. script :: echo "enter build folder name in following sequence L-<REV>_<BUILD>" set BUILD = $< set file= `cat file1` foreach i... (2 Replies)
Discussion started by: arup1980
2 Replies

4. Shell Programming and Scripting

Shell script: foreach file -> targzip

Hi there, I need some help with a shell script (I'm no sh script expert, but I hope this will explain how I want my script):dir = /home/user/files/ foreach(*.jpg file in $dir) { tar -cf $file(-.jpg).tar $file;gzip $file(-.jpg).tar } mv -f $dir*tar.gz /home/user/pictures/ Thanks for any... (12 Replies)
Discussion started by: JKMlol
12 Replies

5. UNIX for Dummies Questions & Answers

foreach shell question

Hi I would like foreach to go through a range of numbers 1-365. This input is being read by a compiled fortran program in the same shell script. Let me try an example to clarify #!/bin/sh foreach i (1-365) ./data_make program <<EOF 'echo $i' /data_'echo $i' #output file I... (10 Replies)
Discussion started by: d_kowalske
10 Replies

6. Shell Programming and Scripting

Foreach loop. Error : Too many words from ``

Hi expert, I have a large text file :- number.txt 1 2 3 4 5 6 .... And i using csh foreach loop to read the file line by line. foreach line(`cat number.txt) set number = $line <Calculation> end (2 Replies)
Discussion started by: vincyoxy
2 Replies

7. Shell Programming and Scripting

Shell Integer with nested foreach

I am scripting in tcsh and here is what I currently have: foreach group (g1 g2 g3 g4) set ppl = `cat $group.file.with.list.of.ppl.in.row.format` set label = 1 @ label += 1 foreach ppls ($ppl) echo $label >> file end end ... (0 Replies)
Discussion started by: bonesy
0 Replies

8. Shell Programming and Scripting

shell to match a pattern

/data}/{bla/${INSTANCE} or /data}/{bla/$INSTANCE the idea is to match a env varialbe name, so it could be between ${ } or a single $ Perl can do it with: perl -ne '/\$\{?(\w+)\}?/;print $1' What shell can do? (8 Replies)
Discussion started by: honglus
8 Replies

9. UNIX for Dummies Questions & Answers

foreach in shell scripting

I need to read list of machines from a file using foreach loop. I am trying the follwing, but its not reading the list foreach i (`cat file.lst | awk '{print $1}'`) ls -l | grep $i end here the file file.lst contains list of files Any idea whats wrong here Thanks Krisyet (2 Replies)
Discussion started by: krisyet
2 Replies

10. Shell Programming and Scripting

foreach syntax error

I wrote a simplistic script which works fine in my HP Korn environment using for in do done but when I converted it for csh it is balking at my syntax specifically the parens for the argument. Any help would be appreciated set -x cut -f1 -d,... (3 Replies)
Discussion started by: r1500
3 Replies
Login or Register to Ask a Question
foreach(1T)						       Tcl Built-In Commands						       foreach(1T)

__________________________________________________________________________________________________________________________________________________

NAME
foreach - Iterate over all elements in one or more lists SYNOPSIS
foreach varname list body foreach varlist1 list1 ?varlist2 list2 ...? body _________________________________________________________________ DESCRIPTION
The foreach command implements a loop where the loop variable(s) take on values from one or more lists. In the simplest case there is one loop variable, varname, and one list, list, that is a list of values to assign to varname. The body argument is a Tcl script. For each element of list (in order from first to last), foreach assigns the contents of the element to varname as if the lindex command had been used to extract the element, then calls the Tcl interpreter to execute body. In the general case there can be more than one value list (e.g., list1 and list2), and each value list can be associated with a list of loop variables (e.g., varlist1 and varlist2). During each iteration of the loop the variables of each varlist are assigned consecutive values from the corresponding list. Values in each list are used in order from first to last, and each value is used exactly once. The total number of loop iterations is large enough to use up all the values from all the value lists. If a value list does not contain enough elements for each of its loop variables in each iteration, empty values are used for the missing elements. The break and continue statements may be invoked inside body, with the same effect as in the for command. Foreach returns an empty string. EXAMPLES
The following loop uses i and j as loop variables to iterate over pairs of elements of a single list. set x {} foreach {i j} {a b c d e f} { lappend x $j $i } # The value of x is "b a d c f e" # There are 3 iterations of the loop. The next loop uses i and j to iterate over two lists in parallel. set x {} foreach i {a b c} j {d e f g} { lappend x $i $j } # The value of x is "a d b e c f {} g" # There are 4 iterations of the loop. The two forms are combined in the following example. set x {} foreach i {a b c} {j k} {d e f g} { lappend x $i $j $k } # The value of x is "a d e b f g c {} {}" # There are 3 iterations of the loop. SEE ALSO
for(1T), while(1T), break(1T), continue(1T) KEYWORDS
foreach, iteration, list, looping ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +--------------------+-----------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +--------------------+-----------------+ |Availability | SUNWTcl | +--------------------+-----------------+ |Interface Stability | Uncommitted | +--------------------+-----------------+ NOTES
Source for Tcl is available on http://opensolaris.org. Tcl foreach(1T)