f(){ read l if [ ${l:1:1} = ${l:2:1} ];then echo ${l:1:1} else echo ${l:4:1} fi f } f