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 256 views
1 answer 259 views
1 answer 331 views
1 answer 256 views
2 answers 325 views
2 answers 286 views
1 answer 227 views
...