bash 版

#!/bin/bash
#sudo apt install translate-shell
cat $1 > $1.txt
for i in `cat $1` ; do
  MD5=$(echo $i | awk '{print gensub(/[!-~]/,"","g",$0)}' | md5sum | awk '{print $1}')
    if [ "68b329da9893e34099c7d8ad5cb9c940" != "$MD5" ];then   #判断是中文就翻译
      TH=$(echo $i | trans -b :th) #翻译为泰语
      PH=$(echo $i | trans -b :ph) #翻译为菲语
      sed -i "s/$i/$TH/" $1.txt
    fi
done

Last updated