let image that we have string:
QQQQQQQ:ABCDE:FFFFFF:GGGGG
in second field can be 0 or 5 characters
if A exist i need set variable ex: VAR=yes
if B exist i need set variable ex: VAR1=yes
if C exist i need set variable ex: VAR2=yes
etc ...
if second field is empty no variable to set
if in second field exist A and C only i need set VAR & VAR2 no others
#!/bin/ksh
str="QQQQQQQ:ABDE:FFFFFF:GGGGG"
set $(echo $str | tr ':' ' ')
if [[ $2 =~ "A" ]]
then
VAR=yes
fi
if [[ $2 =~ "B" ]]
then
VAR1=yes
fi
if [[ $2 =~ "C" ]]
then
VAR2=yes
fi