How do I test whether the first character in an array is a particular character?

i=0
while [ $i -lt $# ]; do
   strng=${args[i]};
   if [ $strng[0] == '-' ]
      echo  ${array[i]}
   let i=i+1
done

Better yet - can I test the first character in an array of strings for a match?

i=0
while [ $i -lt $# ]; do
   array[i]=${args[i]};
   if [ $array[i][0] == '-' ]
      echo  ${array[i]}
   let i=i+1
done

Thanks,
-dog

thanks for sharing about this test.i am new user and looking for this.

# this example tests whether strng starts with the letter 'a'
   if [[ ${strng} == a* ]]    
   then

      echo ${strng}
   fi
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.