User Tools

Site Tools


grep

Grep commands to do various things...

  • grep -v '^\s*$\|^\s*\#' Removes comments and blank lines
  • grep '^r......ing$' /usr/share/dict/words Get all of the 10 letter words starting with an r and ending in ing.
  • The caret(^) marks the beginning of a line, the dollar ($) marks the end.
# Get all the seven letter words that start with a vowel, have a vowel in the fifth position and an r in the seventh position.
grep -E '^[aeiou]...[aeiou].r$' /usr/share/dict/words
amateur
angrier
artsier
atelier
earlier
emptier
itchier
opaquer
outdoor
outwear
unclear
uniquer
untruer

# And this is 'Words that start with two vowels, then two of anything, another vowel, and end in an r'.
grep -E '^[aeiou]{2}..[aeiou]r$' /usr/share/dict/words
airier
author
earner
easier
eerier
either
oilier
ouster

And, a little more grep stuff.

grep.txt · Last modified: by steve