To simplify the discussion, let N = 3.
N = 3
My current approach to extracting the last three characters of every line in a file or stream is to use sed
sed
It's very simple with grep -o '...$':
grep -o '...$'
cat /etc/passwd | grep -o '...$' ash /sh /sh /sh ync /sh /sh /sh
Or better yer:
N=3; grep -o ".\{$N\}$"
That way you can adjust your N for whatever value you like.
N