#154 RE anchors in grep
The ^ or carat represents the start of the line and the $ represents the end of the line.
If we want to query for words that end with “cord” we will use:
grep 'cord$' /usr/share/dict/words
Output:
Concord accord concord cord discord prerecord record whipcord
If we want to list words that begin with “ante” from the dictionary file we will use:
grep '^ante' /usr/share/dict/words
ante ante's anteater anteater's anteaters antebellum antecedent antecedent's antecedents antechamber antechamber's antechambers anted antedate antedated antedates antedating antediluvian anteed anteing antelope antelope's antelopes antenna antenna's antennae antennas anterior anteroom anteroom's anterooms antes
Recent Comments