Reputation: 55
Anyone can tell me what will be the problem?i know that this is a half sec problem but pls help:) egrep "first" a.sh && egrep "second" a.sh
works, a.sh contains first,second,third etc.. Thx!
if [[ egrep "first" a.sh && egrep "second" a.sh ]]; then
echo "success"
fi
Upvotes: 2
Views: 4006
Reputation: 47267
I think this may be what you are looking to do:
found_1=$(egrep "first" a.sh)
found_2=$(egrep "second" a.sh)
if [[ -n "$found_1" ]] && [[ -n "$found_2" ]]; then
echo "success"
fi
Upvotes: 1
Reputation: 798686
Your problem is that you're using the [[
command. Use just the greps.
if egrep ... && egrep ... ; then
Upvotes: 8