$ Match At The End Of Line.

$ Match At The End Of Line.

===> # match lines that end with a "d"

===> grep 'd$' fortunes

The End

===> #match lines ending w/ "/bin/sh"

===> grep '/bin/sh$' /etc/passwd armando:*:201:50:student:/u/armando:/bin/sh

Previous slide Next slide Back to the first slide View Graphic Version

Notes:

In the first example, we’re matching any line that ends with the d character just prior to the newline. Based upon the contents of the fortune file, line 36 satisfies that match from the fortunes file.

In the second example, we’re looking for those lines that match the pattern “/bin/sh” in the /etc/passwd file. This basically prints out those lines (accounts) that use the Bourne shell as their start up shell.