Last active
April 19, 2023 22:03
-
-
Save cpuuntery/5e3078fd1899cb218ec1020aa84bf081 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
GREP WILL NOT WORK WITHOUT THE SINGLE QUOTES | |
JUST LIKE SED USE SINGLE QUOTE AND NEVER USE DOUBLE QUOTES | |
grep -P 'your regex' | |
Print a list of matched files with its match string and with its context, The whole file content will be printed, and the matched string will be coloured differently | |
grep -ri 'regex' | |
Print a list of matched files without its match string | |
grep -ril 'regex' | |
Print a list of matched files without the context of its matched string. The only thing that will be printed out is the file and the matched string. Nothing more and nothing less. | |
grep -rio 'now' | |
Print just the matched string without the name of the file or the context of the match | |
grep -rioh 'now' | |
-P argument makes grep use Perl-compatible regular expression engine because the default grep regex engine is rather weak. Use this with complex regex pattern | |
-r argument makes grep look recursively inside the path that is invoked from | |
-i argument makes grep case-sensitive | |
-o argument hide the context of the matched string | |
-h argument hide the file name of the matched string | |
-B, --before-context=NUM print NUM lines before the matched string | |
-A, --after-context=NUM print NUM lines after the matched string |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment