Skip to main content
1 of 2
Nidal
  • 9.1k
  • 11
  • 59
  • 74

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.

Nidal
  • 9.1k
  • 11
  • 59
  • 74