I'm trying to grep multiple arguments in shell. I put orders like ./script arg1 arg2.. argN And I want them to act egrep -i "arg1" mydata | egrep -i "arg2" | ... egrep -i "argN" | awk -f display.awk in order to match patterns in AND format. What's wrong in my process?
Is it even right to code like egrep -i "arg1" mydata | egrep -i "arg2" | ... egrep -i "argN" | awk -f display.awk to get multiple patterns in AND format??
if [ $# -eq 0 ]
then
echo "Usage:phone searchfor [...searchfor]"
echo "(You didn't tell me what you want to search for.)"
exit 0
else
for arg in $*
do
if [ $arg -eq $1 ]
then
egrep -i "arg" mydata |
else
egrep -i "arg" |
fi
done
awk -f display.awk
fi
If my data has 'happy sunny bunny', 'sleepy bunny', and 'happy sunny'
I want them to perform if I tried ./script happy sunny bunny then only 'happy sunny bunny' comes out.
and if i tried ./script bunny then 'happy sunny bunny' 'sleepy bunny' both coming out.