#! /bin/sh
delete-last-char() {
# for dummyes:
# read(builtin) performs field splitting
# according to $IFS.
# that's why we don't need to strip
# trailing space
while read str; do
echo ${str%?} # omit last non-blank char
done
}
# test case
echo "
9 3 5 6
5 6 1
8 0
" |
delete-last-char