Does any body can help me with a loop in this example?
if [ "$i" -eq 1 -a "$#" -ge 1 ]
then
if [ "$#" -ne 1 ]
then
runner=$(grep "$1" "$2")
runne=$(grep "$1" "$3")
run=$(grep "$1" "$4")
fi
fi
#
# Message on screen or mail or both
#
if [ "$mailopt" = FALSE ]
then
echo "*****************************"
echo "$2:$runner"
echo "$3:$runne"
echo "$4:$run"
echo "*****************************"
else
echo "You have mail!"
run=$(whoami | cut -c1-8)
echo "pattern $1 found in file $2:\
$runner" | mail $run
fi
Instead of specifying $1 $2 $3 with different variables (runner, runne, run). Can you guys help me to change it with a loop so it accepts several files and the output would show the pattern dog in different files
Just what grep does (grep dog file1 file2 file3).
file1: cat dog house
file2: dog cat house
file3: house dog cat
Thanks I just cannot find out how to make that little detail. Thanks.