reverse the order of characters in a string

后端 未结 13 1027
逝去的感伤
逝去的感伤 2020-12-04 15:03

In string \"12345\", out string \"54321\". Preferably without third party tools and regex.

13条回答
  •  [愿得一人]
    2020-12-04 15:34

    read word

    reve=`echo "$word" | awk '{for(i=length($0); i>0;i--) printf (substr($0,i,1));}'`
    echo  "$reve"
    

提交回复
热议问题