Reputation: 179
In the script below RES always returns to nothing; Not sure what I'm doing wrong.
Thanks in advance.
#!/bin/sh
set -x
chk_for() {
RES=0
RES= $(head -1 $1 | fgrep -c "Formula" >&2)
echo "@@@@" || $RES
return $RES
}
for X in /home/wstandke/webcatstats/rep/AnalysisWork/*; do
chk_for "$X"
if [$? == 1]
then
echo "1st line is heading"
file=$(basename $X)
echo "fullname=" || $X
echo "filename=" || $file
mv $X /tmp/$file
sed 1d /tmp/$file > $X
rm /tmp/$file
fi
done
cat /home/wstandke/webcatstats/rep/AnalysisWork/* >/tmp/Analysis.report
Upvotes: 1
Views: 314
Reputation: 5721
You redirect the output of fgrep
to stderr
, thus not assigning any value to RES
.
Also, not sure if that is the problem, but there is a blank after RES=
which might assign blank to RES
.
Try changing the line in question to:
RES=$(head -1 $1 | fgrep -c "Formula")
Upvotes: 2