Skip to content

Instantly share code, notes, and snippets.

@hudolejev
Last active April 13, 2017 08:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hudolejev/81a05791f38cbacfd4de3ee3b44eb4f8 to your computer and use it in GitHub Desktop.
Save hudolejev/81a05791f38cbacfd4de3ee3b44eb4f8 to your computer and use it in GitHub Desktop.
$ 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