while read L;do [[ $L =~ (.)(.*)(.) ]]&&{ M=("${BASH_REMATCH[@]}");echo ${M[3]}${M[2]}${M[1]};}||echo $L;done