for removing the last n
characters from a line that makes no use of sed
OR awk
:
> echo lkj | rev | cut -c (n+1)- | rev
so for example you can delete the last character one character
using this:
> echo lkj | rev | cut -c 2- | rev
> lk
from rev
manpage:
DESCRIPTION
The rev utility copies the specified files to the standard output, reversing the order of characters in every line. If no files are speci- fied, the standard input is read.
UPDATE:
if you don't know the length of the string, try:
$ x="lkj"
$ echo "${x%?}"
lk