I wouldn't really use sed or grep here. You can, but in my opinion, tail is simpler. Use tail to get the last three bytes—we need three to account for the trailing \n character—of the file (note that this won't work if instead of nt you are looking for a more complicated Unicode string where characters can be more than one byte each), and then check if that matches nt:
if [ "$(tail -c3 file)" = "nt" ]];]; then echo yes else echo no fi You could do this with GNU grep, for instance by treating the entire file (assuming it doesn't contain NUL characters) as a single "line" and checking the last characters:
if grep -qPz 'nt\n$' file; then echo yes else echo no fi Or, with sed, something like this (or @steeldriver's better and simpler GNU-specific approach) :
if [ "$(sed -n '${/nt$/p;}' file | wc -c)" -gt 0 ]; then echo yes; else echo no fi Or even perl:
if perl -ne '$l=$_; }{ exit($l=~/nt$/ ? 0 : 1)' file; then echo yes else echo no fi