14,982
edits
| Line 85: | Line 85: | ||
==== by logical operators ==== | ==== by logical operators ==== | ||
'''OR''': match the lines which contains ''pattern1'' OR ''pattern2''<ref>[http://www.linuxquestions.org/questions/linux-newbie-8/logical-operators-in-grep-775595/ logical operators in grep]</ref> | '''OR''': match the lines which contains ''pattern1'' OR ''pattern2''<ref>[http://www.linuxquestions.org/questions/linux-newbie-8/logical-operators-in-grep-775595/ logical operators in grep]</ref><ref>[http://www.thegeekstuff.com/2011/10/grep-or-and-not-operators/ 7 Linux Grep OR, Grep AND, Grep NOT Operator Examples]</ref> | ||
* {{kbd | key = <nowiki>awk '/pattern1|pattern2/' file_name </nowiki>}} for {{Linux}} | * {{kbd | key = <nowiki>awk '/pattern1|pattern2/' file_name </nowiki>}} for {{Linux}} | ||
* {{kbd | key = <nowiki>grep 'pattern1\|pattern2' file_name </nowiki>}} | * {{kbd | key = <nowiki>grep 'pattern1\|pattern2' file_name </nowiki>}} | ||
| Line 93: | Line 93: | ||
* {{kbd | key = <nowiki>awk '/pattern1/&&/pattern2/' file_name </nowiki>}} for {{Linux}} | * {{kbd | key = <nowiki>awk '/pattern1/&&/pattern2/' file_name </nowiki>}} for {{Linux}} | ||
* {{kbd | key = <nowiki>grep -E 'pattern1.*pattern2|pattern2.*pattern1' file_name </nowiki>}} {{exclaim}} order dependent | * {{kbd | key = <nowiki>grep -E 'pattern1.*pattern2|pattern2.*pattern1' file_name </nowiki>}} {{exclaim}} order dependent | ||
=== Search text in single plain text file === | === Search text in single plain text file === | ||