# !/bin/bash
# 20051123 man_encode_converter.sh hse@ukr.net http://docs.linux.org.ua/dlou/index.php/Man
# Distributed under the terms of the GNU General Public License v2 or later
# This script convert installed man page from one encoding to another.
# Edit to suite yours configuration:
# Man path:
manpath=/usr/share/man/ru
# From which encoding:
fromencode='koi8-r'
# To which encoding
toencode='utf8'
# If some page was compressed which archivator and how to use and what extensions they have:
archivator='/bin/gzip -dq'
ext='gz'
for i in 1 2 3 4 5 6 7 8 9 0p 1p 3p n s
do
if [ -d $manpath/man$i ]
then
cd $manpath/man$i/
for j in `ls $manpath/man$i`
do
if <span class="createlink"><a href="/cgi-bin/ikiwiki.cgi?page=awk_-F__39__.__39_____39____123__print___36__3__125____39____96_____61____61_____34____36__ext__34_____124____124_____96__echo___36__j___124__awk_-F__39__.__39_____39____123__print___36__4__125____39____96_____61____61_____34____36__ext__34_____124____124_____96__echo___36__j___124__awk_-F__39__.__39_____39____123__print___36__5__125____39____96_____61____61_____34____36__ext__34___&from=man%2F%D0%A0%D0%B5%D0%B4%D0%B0%D0%B3%D1%83%D0%B2%D0%B0%D0%BD%D0%BD%D1%8F_%D1%81%D1%82%D0%BE%D1%80%D1%96%D0%BD%D0%BE%D0%BA_%D0%BF%D1%96%D0%B4%D1%80%D1%83%D1%87%D0%BD%D0%B8%D0%BA%D0%B0%2Fman_encode_converter.sh&do=create" rel="nofollow">?</a> `echo $j </span>
then
file=`echo $j |awk -F'.' '{print $1}'`.`echo $j |awk -F'.' '{print $2}'`
if <span class="createlink"><a href="/cgi-bin/ikiwiki.cgi?page=awk_-F__39__.__39_____39____123__print___36__3__125____39____96_____33____61_____34____36__ext__34___&from=man%2F%D0%A0%D0%B5%D0%B4%D0%B0%D0%B3%D1%83%D0%B2%D0%B0%D0%BD%D0%BD%D1%8F_%D1%81%D1%82%D0%BE%D1%80%D1%96%D0%BD%D0%BE%D0%BA_%D0%BF%D1%96%D0%B4%D1%80%D1%83%D1%87%D0%BD%D0%B8%D0%BA%D0%B0%2Fman_encode_converter.sh&do=create" rel="nofollow">?</a> `echo $j </span>
then
file=$file.`echo $j |awk -F'.' '{print $3}'`
if <span class="createlink"><a href="/cgi-bin/ikiwiki.cgi?page=awk_-F__39__.__39_____39____123__print___36__4__125____39____96_____33____61_____34____36__ext__34___&from=man%2F%D0%A0%D0%B5%D0%B4%D0%B0%D0%B3%D1%83%D0%B2%D0%B0%D0%BD%D0%BD%D1%8F_%D1%81%D1%82%D0%BE%D1%80%D1%96%D0%BD%D0%BE%D0%BA_%D0%BF%D1%96%D0%B4%D1%80%D1%83%D1%87%D0%BD%D0%B8%D0%BA%D0%B0%2Fman_encode_converter.sh&do=create" rel="nofollow">?</a> `echo $j </span>
then
file=$file.`echo $j |awk -F'.' '{print $4}'`
fi
fi
($archivator $manpath/man$i/$j)
(cat $manpath/man$i/$file |iconv -f $fromencode -t $toencode > $manpath/tmp)
mv -f $manpath/tmp $manpath/man$i/$file
bzip2 -zf9 $manpath/man$i/$file
else
(cat $manpath/man$i/$j |iconv -f $fromencode -t $toencode > $manpath/tmp)
mv -f $manpath/tmp $manpath/man$i/$j
fi
done
fi
done
exit 0