Skip to content

Instantly share code, notes, and snippets.

@hudolejev
Last active April 13, 2017 08:02
$ echo 'afoobarfoobar' > a.txt
$ echo 'xyzzyfoobarfoobarfoo' > b.txt
# Print all occurrences in all files
$ grep -o foo a.txt b.txt
a.txt:foo
a.txt:foo
b.txt:foo
b.txt:foo
b.txt:foo
# Print number of occurrences per file
$ grep -o foo a.txt b.txt | sort | uniq -c
2 a.txt:foo
3 b.txt:foo
# Grep version
$ grep -V
grep (GNU grep) 2.25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment