|
|||||||
| Forums | Search Forums | Register | Forum Rules | Man Pages | Albums | FAQ | Members | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
|
|
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
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. Code:
#!/bin/csh -fxv
if (! $#argv==1); then
echo "[fail, not enough input arguments]"
exit 10
else
echo "the pitch and kinf will be stored in a new file called" $1
echo " "
endif
rm $1
# uncompress output files in directory
set list= `/bin/ls *.out.gz`
foreach f ($list)
gunzip $f
end
#run the pearl script on each output file and compress that file
set list= `/bin/ls *.out`
foreach i ($list)
./readfile.pl $i $1
gzip $i
end
exit 0Last edited by fpmurphy; 10-05-2012 at 11:38 PM.. |
| Sponsored Links | ||
|
|
#2
|
||||
|
||||
|
# The shell expands meta-characters, so try this: Code:
foreach f ( *.out.gz ) gunzip $f end |
| Sponsored Links | ||
|
|
#3
|
||||
|
||||
|
Try replacing Code:
set list= `/bin/ls *.out` with Code:
set list=(`/bin/ls *.out`) |
| Sponsored Links | ||
|
![]() |
| Thread Tools | Search this Thread |
| Display Modes | |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Shell script: foreach file -> targzip | JKMlol | Shell Programming and Scripting | 12 | 06-15-2010 05:48 AM |
| foreach shell question | d_kowalske | UNIX for Dummies Questions & Answers | 10 | 07-14-2009 06:55 PM |
| Shell Integer with nested foreach | bonesy | Shell Programming and Scripting | 0 | 04-29-2009 11:09 PM |
| C Shell - foreach - No Match error | adurga | Shell Programming and Scripting | 0 | 04-26-2009 04:53 AM |
| foreach in shell scripting | krisyet | UNIX for Dummies Questions & Answers | 2 | 08-11-2006 10:29 AM |
|
|