We would like to get the string that ends with the given search term. For this use $ operator - we place this operator at the end of search term.
Example 1:
$ grep 'sam$' names.txt
basam
Example 2:
$ grep '7$' /etc/login.defs
ERASECHAR 0177
PASS_WARN_AGE 7
Example 3:
$ grep 'mail$' /etc/login.defs
MAIL_DIR /var/mail
#MAIL_FILE .mail