jeudi 25 août 2016

BASH if 9th character in a line is a specific letter; then

How to perform some steps if the 9th character of a line "$q" is an A, B, C, D, or E. Something like?

if [ ${q:9} == [A,B,C,D,E]; then

(If the 9th character is a capital A, B, C, D, or E, than do; )

I've used if [ ${q:9} == A ]; to match one letter, and was trying to construct something like the above or: if [[ "${p:9}" == "A" && "$p" == "B" && "$p" == "C" "$p" == "D" "$p" == "E"]]; then to match multiple letters, but does not seem to work regardless of the operator I use.

Aucun commentaire:

Enregistrer un commentaire