How to extract the first two characters of a string in Bash

1 Answer

0 votes
s="bash Unix shell and command language"
 
firsttwocharacters=${s::2}

echo $firsttwocharacters
 
 
 
# run:
#
# ba
#

 



answered Feb 6, 2021 by avibootz

Related questions

1 answer 264 views
1 answer 230 views
2 answers 587 views
1 answer 263 views
2 answers 293 views
2 answers 361 views
1 answer 250 views
250 views asked May 28, 2021 by avibootz
...