Quote:
Originally Posted by happyv
Hello,
I have the following script to restore file and grep information. However, once it restore file, it showing a lot useless information and different to check which file have the statement "John price $200". Can I not show any information while running script. It only show..when found the string?
echo Please input list file name:
read listn
for file in `cat $listn.txt`
do
restore_file $file
cat $file |grep "John price $200"
done
expect output:
filename: XXXXXX
found string: John price $200
|
Try this:
Code:
echo Please input list file name:
read listn
for file in `cat $listn.txt`
do
restore_file $file > /dev/null 2>&1
grep "John price $200" $file > /dev/null 2>&1
(( ! $? )) && printf "filename: $file \nfound string: \"John price $200\"\n"
done
(not tested)
Regards.