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
Pure bash solution:
$ while read -r in; do echo "${in: -3}"; done hello llo $
$ sed 's,.*\(.\{3\}\)$,\1,' hallo llo $