Skip to content

Instantly share code, notes, and snippets.

@korovamilk
Created September 12, 2014 09:42
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 korovamilk/d18ca6555d7f7006e51d to your computer and use it in GitHub Desktop.
Save korovamilk/d18ca6555d7f7006e51d to your computer and use it in GitHub Desktop.
Find Pattern in file and print matching strings when occurencies > 1 (per line)
# example email - real name list "<filename>"
# (note that name4 entry is broken - email appears 2 times
name1@example.com;"Real Name"
name2@example.com;"Real Name"
name3@example.com;"Real Name"
name4@example.com;name4@example.com;"Real Name"
# following awk will find and print the lines with MORE than one matching pattern
# (here I grep for "@")
$ awk '{n=split($0,c,"@")-1;if (n>1) print $0 }' <filename>
name4@example.com;name4@example.com;"Real Name"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment