How to remove the last N characters of a string in Bash

1 Answer

0 votes
s="bash Unix shell and command language"

N=5
s=${s::-N}

echo $s



# run:
#
# bash Unix shell and command lan
# 

 



answered Feb 5, 2021 by avibootz

Related questions

1 answer 362 views
1 answer 386 views
1 answer 463 views
1 answer 355 views
2 answers 482 views
2 answers 405 views
1 answer 345 views
...