1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46
|
#!/bin/sh
grep "zZ" $1 && exit 1
LC_CTYPE=C
export LC_CTYPE
cp $1 $1.bak || exit 1
LINES1=`cat $1 | wc -l`
sed -e 's//czZ/g' -e 's//CzZ/g' \
-e 's//gzZ/g' -e 's//GzZ/g' \
-e 's//hzZ/g' -e 's//HzZ/g' \
-e 's//jzZ/g' -e 's//JzZ/g' \
-e 's//szZ/g' -e 's//SzZ/g' \
-e 's//uzZ/g' -e 's//UzZ/g' \
-e 's/\(\\[^a-zA-Z]\)\([a-zA-Z]\)/\2zZ{\1}/g' \
-e 's/\(\\[a-zA-Z]\){\([a-zA-Z]\)}/\2zZzZ{\1}/g' \
-e 's/{\\\([a-zA-Z]\)\([a-zA-Z]*\)}/\1zZ{}{\2}/g' \
< $1 > temp && sort -d -f -k2,2 -k1,1 temp | uniq |\
sed -e 's/\([a-zA-Z]\)zZ{}{\([^}]*\)}/{\\\1\2}/g' \
-e 's/\([a-zA-Z]\)zZzZ{\([^}]*\)}/\2{\1}/g' \
-e 's/\([a-zA-Z]\)zZ{\([^}]*\)}/\2\1/g' \
-e 's/czZ//g' -e 's/CzZ//g' \
-e 's/gzZ//g' -e 's/GzZ//g' \
-e 's/hzZ//g' -e 's/HzZ//g' \
-e 's/jzZ//g' -e 's/JzZ//g' \
-e 's/szZ//g' -e 's/SzZ//g' \
-e 's/uzZ//g' -e 's/UzZ//g' \
> $1 || exit 2
LINES2=`cat $1 | wc -l`
if [ `expr $LINES1 \- $LINES2` -gt 9 ]
then
echo "File $1 has shrinked a lot! Stop."
exit 9
fi
tail -1 $1 | grep zzz && rm temp $1.bak && exit 0
echo "Endmark 'zzz' is missing. Backup files temp and $1.bak are preserved"
exit 3
# Local variables:
# coding: latin-3
# end:
|