#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:

1grep 'cord$' /usr/share/dict/words

Output:

1Concord
2accord
3concord
4cord
5discord
6prerecord
7record
8whipcord

If we want to list words that begin with “ante” from the dictionary file we will use:

1grep '^ante' /usr/share/dict/words
1ante
2ante's
3anteater
4anteater's
5anteaters
6antebellum
7antecedent
8antecedent's
9antecedents
10antechamber
11antechamber's
12antechambers
13anted
14antedate
15antedated
16antedates
17antedating
18antediluvian
19anteed
20anteing
21antelope
22antelope's
23antelopes
24antenna
25antenna's
26antennae
27antennas
28anterior
29anteroom
30anteroom's
31anterooms
32antes

Discover more from Tips and Hints for Aerospace Engineers

Subscribe now to keep reading and get access to the full archive.

Continue reading