I know that the
cut command can print the first
n characters of a string but how to select the last
If I have a string with a variable number of characters, how can I print only the last three characters of the string. eg.
"unlimited" output needed is "ted" "987654" output needed is "654" "123456789" output needed is "789"
Why has nobody given the obvious answer?
… or the slightly less obvious
grep -o '...$'
Admittedly, the second one has the drawback that lines with fewer than three characters vanish; but the question didn’t explicitly define the behavior for this case.