软件 把 Linux 格式文本转换成 DOS 格式

转载自huahua的blog: http://huangjiahua.livejournal.com/
把 Linux 格式文本转换成 DOS 格式
hua@vgh:~$ cat ~/bin/linux2windoze.sh
#!/bin/sh
#
# 把 Linux 格式文本转换成 DOS 格式
# UTF-8 转换为 GBK , \n 换成 \r\n
#

case $1 in
-h | –help)
echo usage: $0 FILES
exit 0
;;
-v | –version)
cat $0
exit 0
;;
esac

for fn in $@
do
echo $fn
iconv -f utf8 -t GBK -s < "$fn" | sed ‘s/\n/\r\n/g’ > “$fn”.tmp \
&& mv “$fn”.tmp “$fn”
done

This entry was posted in GNU/Linux and tagged . Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *