I have the following script and want to check if in each $f there exists either a "drw" or "smp" tag in the file name. How can I do it?
For example
npt06-32x24drw has the "drw" tag
npt06-32x24smp has the "smp" tag
npt06-32x24 no "drw" or "smp" tag found
#!/bin/csh
set iarg = 0
set optusage = 0
set opteg = 0
set opthelp = 0
set optinfo = 0
set fnames = ""
alias MATH 'set \!:1 = `echo "\!:3-$" | bc -l`'
set narg = $#argv
while ($iarg < $narg)
MATH iarg = $iarg + 1
set arg = $argv[$iarg]
set opt = ` echo $arg | awk 'BEGIN { FS="=" } { print $1 }' \
| tr "[a-z]" "[A-Z]" `
set par = ` echo $arg | awk 'BEGIN { FS="=" } { print $2 }' `
switch ($opt)
case "-USAGE":
set optusage = 1
set optinfo = 1
breaksw
case "-EG":
set opteg = 1
set optinfo = 1
breaksw
case "-HELP":
set opthelp = 1
set optinfo = 1
breaksw
default:
set flog = `echo $arg | awk 'BEGIN {FS=".log"} {print $1}'`
set fnames = "$fnames $flog"
endsw
end # while
if ($fdrw) then
foreach f ($fnames)
echo "(I) ${f}.log, (O) ${f}.mis"
grep "Rms Value" $f*.log \
| awk '{ if ($0 !~ /run[0-9]+\.log:0\. /) \
{ sub(/[^:]*:[0-9]*\.[ \t]*/,x); print i++". " $0 } \
}' > $f.mis
grep "Best Value" $f*.log \
| awk '{ if ($0 !~ /run[0-9]+\.log:0\. /) \
{ sub(/[^:]*:[0-9]*\.[ \t]*/,x); print i++". " $0 } \
}' >> $f.mis
end
elseif ($fsmp) then
foreach f ($fnames)
echo "(I) ${f}.log, (O) ${f}.mis"
grep "Best Value" $f*.log \
| awk '{ if ($0 !~ /run[0-9]+\.log:0\. /) \
{ sub(/[^:]*:[0-9]*\.[ \t]*/,x); print i++". " $0 } \
}' >> $f.mis
endif
echo ""
echo "END"
echo ""