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
break(3tcl)						       Tcl Built-In Commands						       break(3tcl)

__________________________________________________________________________________________________________________________________________________

NAME
break - Abort looping command SYNOPSIS
break _________________________________________________________________ DESCRIPTION
This command is typically invoked inside the body of a looping command such as for or foreach or while. It returns a TCL_BREAK code, which causes a break exception to occur. The exception causes the current script to be aborted out to the innermost containing loop command, which then aborts its execution and returns normally. Break exceptions are also handled in a few other situations, such as the catch com- mand, Tk event bindings, and the outermost scripts of procedure bodies. EXAMPLE
Print a line for each of the integers from 0 to 5: for {set x 0} {$x<10} {incr x} { if {$x > 5} { break } puts "x is $x" } SEE ALSO
catch(3tcl), continue(3tcl), for(3tcl), foreach(3tcl), return(3tcl), while(3tcl) KEYWORDS
abort, break, loop Tcl break(3tcl)