Created
November 15, 2020 10:13
-
-
Save fieldse/24afdc852eaeb6622976a4098b64e1f7 to your computer and use it in GitHub Desktop.
Grep/zgrep: count matches across multiple files
This file contains 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
# Count occurences of KEYWORD across all files named [something].log | |
# Flag: -src | |
# Credit: | |
# https://superuser.com/questions/205591/show-the-matching-count-of-all-files-that-contain-a-word | |
grep -src KEYWORD *.log | |
# Example output: | |
# production.20201107.log:12 | |
# production.20201108.log:0 | |
# production.20201109.log:0 | |
# production.20201110.log:0 | |
# production.20201111.log:0 | |
# production.20201112.log:21 | |
# Zgrep: Count occurences of KEYWORD across gzipped files | |
# Same syntax | |
zgrep -src KEYWORD *.gz |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment