Last active
September 30, 2024 03:42
-
-
Save henri/39a1213717f76a0d892c0051fe77a98e to your computer and use it in GitHub Desktop.
grep_cheatsheet
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
# select lines which start with upper case or lower case letter at the start of the line | |
grep -E "^[a-z]|[A-Z]" | |
# enable line buffering (useful for dealing with pipes and real time loops) | |
grep --line-buffered "search term" | |
# enable highlighting for a match but do not filter output (all of these examples will have a similar effect) | |
ack --passthru 'hightlight-match-string' | |
grep "^\|highlight-match-string" --color="always" | |
grep "^\|highlight-match-string" --color | |
grep "^\|highlight-match-string" | |
grep "\|highlight-match-string" | |
# use sponge to soak up a file and then write back to the same file (grep goodnes) | |
cat remove_lines_from_me.txt | grep -vx --fixed-strings --file=delete_pattern_file_one_per_line.pattern | sponge remove_lins_from_me.txt | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment