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 386 views
1 answer 316 views
2 answers 736 views
1 answer 362 views
2 answers 405 views
2 answers 493 views
1 answer 360 views
360 views asked May 28, 2021 by avibootz
...