How do you locate lines beginning and ending with a dot using grep and sed commad?

1 answer

Answer

1181889

2026-04-02 20:16

+ Follow

grep can match the beginning of a line with the '^' character and the end of a line with the '$' character. Any character is matched by the '.' character, so to match a literal "." you will need to use the escaped '\.' sequence. Thus to match a line beginning with a dot and ending with a dot you would use:

grep '^\..*\.$'

This will match any line that both begins with a dot and ends with a dot, and has any characters in between.

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.