Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

2 grep in if statement

Tags:

bash

shell

unix

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
like image 432
Smithis Avatar asked Mar 19 '26 21:03

Smithis


1 Answers

Your problem is that you're using the [[ command. Use just the greps.

if egrep ... && egrep ... ; then
like image 109
Ignacio Vazquez-Abrams Avatar answered Mar 22 '26 13:03

Ignacio Vazquez-Abrams



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!