有人可以帮我写ascript来翻译每行中的第三个单词,单词用制表符分隔.
样本输入:
Hello how Are You Iam Fine how about
样本输出:
Hello how Ziv You Iam Fine sld about
每行中的第三个单词应翻译为使用:tr'[abcdefghijklmnopqrstuvqxyz]”[zyxwvutsrqponmlkjihgfedcba]’
解决方法
鉴于以下内容:
[somedude@dev7 ~]# cat so.txt Hello how Are You Iam Fine how about [somedude@dev7 ~]#
我跑了:
[somedude@dev7 ~]# cat so.sh #!/bin/bash _INPUT="Hello how Are You Iam Fine how about" # read each line from config file while read -r l do _GET_THIRD_WORD=$(echo $l | awk '{print $3}') echo $_GET_THIRD_WORD | sed -i "s,$_GET_THIRD_WORD,SOMETHINGTOTRANSLATEWITH," done < so.txt [somedude@dev7 ~]#
这将使您的每个翻译行回显到标准输出.
希望这可以帮助!