How to get the first N characters from a string in Bash

2 Answers

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

N=6
s=${s::N}

echo $s



# run:
#
# bash U
# 

 



answered Feb 5, 2021 by avibootz
0 votes
s="bash Unix shell and command language"

N=6
s=${s:0:N}

echo $s



# run:
#
# bash U
# 

 



answered Feb 5, 2021 by avibootz

Related questions

1 answer 360 views
1 answer 332 views
1 answer 316 views
1 answer 318 views
2 answers 435 views
1 answer 393 views
2 answers 735 views
...