置換のリストを手元に用意して、翻訳のために呼び出す必要があると思います。テキスト ファイルを効率的に翻訳するには、辞書ファイルを充実させる必要があります。
sourceFile=$1
dict=$2
while read line
do
word=$(echo $line |awk '{print $1}')
updatedWord=$(grep -i $word $dict|awk '{print $2}')
sed -i "s/$word/$updatedWord/g" $sourceFile 2 > /dev/null
done < $dict
上記のスクリプトを次のように実行します。
./scriptName source.txt dictionary.txt
以下は、私が使用したサンプル辞書の 1 つです。
>cat dict
characterize characterise
prioritize prioritise
specialize specialise
analyze analyse
catalyze catalyse
size size
exercise exercise
behavior behaviour
color colour
favor favour
contour contour
center centre
fiber fibre
liter litre
parameter parameter
ameba amoeba
anesthesia anaesthesia
diarrhea diarrhoea
esophagus oesophagus
leukemia leukaemia
cesium caesium
defense defence
practice practice
license licence
defensive defensive
advice advice
aging ageing
acknowledgment acknowledgement
judgment judgement
analog analogue
dialog dialogue
fulfill fulfil
enroll enrol
skill, skillful skill, skilful
labeled labelled
signaling signalling
propelled propelled
revealing revealing
実行結果:
cat source
color of this fiber is great and we should analyze it.
./ScriptName source.txt dict.txt
cat source
colour of this fibre is great and we should analyse it.