INF=dict-ru.xml OUTF=dict-ru-yo.xml YOF=yo-words TMPF=$(mktemp) trap "rm -f $TMPF" EXIT cat yo.txt | dos2unix | iconv -f cp1251 -t utf8 | sed '1,2d' | sed 's/(.*$//' | sed 's/,/\n/g' | sort | uniq > $YOF for w in $(cat yo-words); do ww=$(echo $w | sed 's/ё/е/') out=$(fgrep ">${ww}<" $INF) || continue out2=$(echo $out | sed "s/${ww}/${w}/") #echo w=$w ww=$ww out=$out out2=$out2 echo "$out2" >> $TMPF done cat $TMPF | sort | uniq > yo.xml