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 245 views
1 answer 246 views
1 answer 314 views
1 answer 249 views
2 answers 314 views
2 answers 272 views
1 answer 215 views
...