10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
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
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
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
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
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
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
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
/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
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
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
continue(3tcl) Tcl Built-In Commands continue(3tcl)
__________________________________________________________________________________________________________________________________________________
NAME
continue - Skip to the next iteration of a loop
SYNOPSIS
continue
_________________________________________________________________
DESCRIPTION
This command is typically invoked inside the body of a looping command such as for or foreach or while. It returns a TCL_CONTINUE code,
which causes a continue exception to occur. The exception causes the current script to be aborted out to the innermost containing loop
command, which then continues with the next iteration of the loop. Catch exceptions are also handled in a few other situations, such as
the catch command and the outermost scripts of procedure bodies.
EXAMPLE
Print a line for each of the integers from 0 to 10 except 5:
for {set x 0} {$x<10} {incr x} {
if {$x == 5} {
continue
}
puts "x is $x"
}
SEE ALSO
break(3tcl), for(3tcl), foreach(3tcl), return(3tcl), while(3tcl)
KEYWORDS
continue, iteration, loop
Tcl continue(3tcl)