How to check the first character of a string in Bash

1 Answer

0 votes
s="bash Unix shell and command language"
 
if [[ ${s::1} == "b" ]]
then
  echo 1;
else
  echo 0; fi
 
 
 
# run:
#
# 1
#

 



answered Feb 6, 2021 by avibootz

Related questions

1 answer 314 views
2 answers 285 views
2 answers 279 views
1 answer 211 views
1 answer 215 views
1 answer 249 views
2 answers 567 views
...