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(1)							   User Commands							  break(1)

NAME
break, continue - shell built-in functions to escape from or advance within a controlling while, for, foreach, or until loop SYNOPSIS
sh break [n] continue [n] csh break continue ksh *break [n] *continue [n] DESCRIPTION
sh The break utility exits from the enclosing for or while loop, if any. If n is specified, break n levels. The continue utility resumes the next iteration of the enclosing for or while loop. If n is specified, resume at the n-th enclosing loop. csh The break utility resumes execution after the end of the nearest enclosing foreach or while loop. The remaining commands on the current line are executed. This allows multilevel breaks to be written as a list of break commands, all on one line. The continue utility continues execution of the next iteration of the nearest enclosing while or foreach loop. ksh The break utility exits from the enclosed for, while, until, or select loop, if any. If n is specified, then break n levels. If n is greater than the number of enclosing loops, the outermost enclosing loop shall be exited. The continue utility resumes the next iteration of the enclosed for, while, until, or select loop. If n is specified then resume at the n- th enclosed loop. If n is greater than the number of enclosing loops, the outermost enclosing loop shall be used. On this man page, ksh(1) commands that are preceded by one or two * (asterisks) are treated specially in the following ways: 1. Variable assignment lists preceding the command remain in effect when the command completes. 2. I/O redirections are processed after variable assignments. 3. Errors cause a script that contains them to abort. 4. Words that follow a command preceded by ** that are in the format of a variable assignment are expanded with the same rules as a vari- able assignment. This means that tilde substitution is performed after the = sign, and also that word splitting and file name genera- tion are not performed. ATTRIBUTES
See attributes(5) for descriptions of the following attributes: +-----------------------------+-----------------------------+ | ATTRIBUTE TYPE | ATTRIBUTE VALUE | +-----------------------------+-----------------------------+ |Availability |SUNWcsu | +-----------------------------+-----------------------------+ SEE ALSO
csh(1), exit(1), ksh(1), sh( 1), attributes(5) SunOS 5.10 17 Jul 2002 break(1)