tvrman
1
Hi all,
Can egrep using AND OR ?, like egrep -i "title.$1" AND "category.$2" ./home....
I want to give two search criteria, the files where egrep is seaching in for example
looks like below rows.
title this is an test
category space
(command line input)
$1 script.sh this space
thanks
With egrep:
search for $var1 OR $var2:
egrep "[$var1]|[$var2]" file
search for $var1 AND $var2:
egrep "$var1.*$var2|$var2.*$var1" file
Regards
tvrman
3
Thank you, that's exact what i need.
era
4
Actually the examples are wrong. But this is a duplicate of another thread; see Need Help with Simple Regex - Page 3
tvrman
5
Hi Era,
thank you very much, this should be the solution? var1.*var2|var2.*var1, should this create the AND?
era
6
Yes, that checks for var1 and var2 on one and the same line, in any order.
tvrman
7
thanks Era, just what i was looking for.