read -da s n t for((;i++<2&&n--;)){ v= for u in $s;{ u+=\ for j in 0 2 1 3 1 0 2 3;{ v+=${u:j:1} } } s=$v } ${s/*$t*/: FAILURE}||SUCCESS echo $_