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 331 views
2 answers 294 views
2 answers 288 views
1 answer 223 views
1 answer 227 views
1 answer 256 views
2 answers 578 views
...