Skip to main content
Haui's Bytes
  • Source
  • Archive
  • Tags
  • RSS feed
  • Disclaimer

Remove the last character from a string/variable (bash)

Haui

2008-08-11 12:00

Source

echo ${var:0:${#var}-1}
echo ${var%?}
echo $var | sed 's/.$//'

You could also use chop ;)

  • linux
  • Previous post
  • Next post
Contents © 2019 Haui - Powered by Nikola