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 256 views
1 answer 228 views
1 answer 224 views
1 answer 208 views
2 answers 288 views
1 answer 300 views
2 answers 578 views
...