Skip to content

Instantly share code, notes, and snippets.

@Nan-Zhang
Last active August 29, 2015 14:10
Show Gist options
  • Save Nan-Zhang/9e424a78de6db9b0ede7 to your computer and use it in GitHub Desktop.
Save Nan-Zhang/9e424a78de6db9b0ede7 to your computer and use it in GitHub Desktop.

count the number of phone number

grep -E "[0-9]{3}-[0-9]{7}" ./test/* | wc -l

show the filename which contain the phone number

grep -lE "[0-9]{3}-[0-9]{7}" ./test/*
-E activates regular expressions (you could use egrep instead)
-l filters grep results, only the file name will be printed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment