9 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. UNIX for Dummies Questions & Answers
It's been a while since I used csh formatting and I am having a little bit of trouble with a few things. Things seem so much easier to execute in Matlab, however I need to do this on the terminal because of the programs I am trying to interact with.
So here's what I want to do: I have a file... (0 Replies)
Discussion started by: katia
0 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. Shell Programming and Scripting
I have two arrays
@nextArray contains some files like
\main\1\Xul.xml@@\main\galileo_integration_sjc\0
\main\1\PortToStorageDialog.xml@@\main\galileo_integration_sjc\0
.
.
.
\main\1\PreferencesDialog.xml@@\main\galileo_integration_sjc\0
@otherArray contains some files like
... (2 Replies)
Discussion started by: nmattam
2 Replies
6. 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
7. Shell Programming and Scripting
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... (0 Replies)
Discussion started by: adurga
0 Replies
8. Shell Programming and Scripting
Hi can someone tell me whats wrong with the following:
#!/bin/sh
file1=$1
file2=$2
if
then
if
then
echo "File 1 is" $file1
echo "File 2 is" $file2
cp $file1 $file2
echo "Copy complete!"
else
echo "ERROR: File does not exist!"
... (8 Replies)
Discussion started by: philmetz
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