windows下文档格式转换 为unix文档格式注意事项
2017-07-31 17:15
483 查看
1、windows使用dos模式结尾,unix采用unix格式结尾。
find -name "*.h" -o -name "*.cpp" | xargs dos2unix
2、windows一般使用GBK编码格式,linux采用utf-8格式。解决办法:
#!bin/bash
if [ -f "tmp.log" ]; then
rm tmp.log
fi
find -name "*.cpp" -o -name "*.h" -o -name "*.jce"|xargs file -i|grep 8859|awk '{print $1}' >> tmp.log
cat tmp.log | while read line
do
var=${line:0:(${#line}-1)}
echo $var
iconv -f GBK -t utf-8 $var -o $var'.bak' && rm $var && mv $var'.bak' $var
done
rm tmp.log
3、综合性语句:技能把dos转换为unix又能把GBK格式转换为utf-8格式
#!bin/bash
pwd
find -name "*.cpp" -o -name "*.h" | xargs file -i|grep 8859|awk '{print $1}' >> tmp.log
cat tmp.log | while read line
do
var=${line:0:(${#line}-1)}
echo $var
iconv -f GBK -t utf-8 $var -o $var'.bak' && rm $var && mv $var'.bak' $var
done
rm tmp.log
find -name "*.h" -o -name "*.cpp"|xargs file| grep CRLF| awk '{print $1}' >> tmp.log
cat tmp.log | while read line
do
var=${line:0:(${#line}-1)}
echo $var
dos2unix $var
done
rm tmp.log
find -name "*.h" -o -name "*.cpp" | xargs dos2unix
2、windows一般使用GBK编码格式,linux采用utf-8格式。解决办法:
#!bin/bash
if [ -f "tmp.log" ]; then
rm tmp.log
fi
find -name "*.cpp" -o -name "*.h" -o -name "*.jce"|xargs file -i|grep 8859|awk '{print $1}' >> tmp.log
cat tmp.log | while read line
do
var=${line:0:(${#line}-1)}
echo $var
iconv -f GBK -t utf-8 $var -o $var'.bak' && rm $var && mv $var'.bak' $var
done
rm tmp.log
3、综合性语句:技能把dos转换为unix又能把GBK格式转换为utf-8格式
#!bin/bash
pwd
find -name "*.cpp" -o -name "*.h" | xargs file -i|grep 8859|awk '{print $1}' >> tmp.log
cat tmp.log | while read line
do
var=${line:0:(${#line}-1)}
echo $var
iconv -f GBK -t utf-8 $var -o $var'.bak' && rm $var && mv $var'.bak' $var
done
rm tmp.log
find -name "*.h" -o -name "*.cpp"|xargs file| grep CRLF| awk '{print $1}' >> tmp.log
cat tmp.log | while read line
do
var=${line:0:(${#line}-1)}
echo $var
dos2unix $var
done
rm tmp.log
相关文章推荐
- 用openoffice 在windows和linux系统中 转换文件格式 注意地方!
- 多操作系统平台协同开发时 GIT 的注意事项: 不同操作系统中的换行符(不要使用git的换行符自动转换功能,并且,尽可能保证代码的换行符都是unix); 避免使用第三方插件(如 EGit );
- unix格式转换成windows格式
- Windows & Unix 文件格式之迷, 空格、回车换行、tab 转换及其相关工具(转载)
- Windows & Unix 文件格式之迷, 空格 与 tab 转换及其相关工具
- DOS/Windows和Linux/Unix的文件格式转换(转载)
- 【转载】DOS/Windows和Linux/Unix间的文件格式转换
- 【python3】文件格式转换windows转为unix
- [转]多操作系统平台协同开发时 GIT 的注意事项: 不同操作系统中的换行符(不要使用git的换行符自动转换功能,并且,尽可能保证代码的换行符都是unix); 避免使用第三方插件(如 EGit );
- 将windows文本格式转换为UNIX格式
- C#格式转换注意事项
- Windows & Unix 文件格式之迷, 空格 与 tab 转换及其相关工具
- DOS/Windows和Linux/Unix间的文件格式转换
- Windows/Unix文本格式转换导致“/usr/bin/env: No such file or directory”
- Windows & Unix 文件格式之迷, 空格、回车换行、tab 转换及其相关工具
- Notepad++中Windows,Unix,Mac三种格式之间的转换
- DOS/Windows和Linux/Unix的文件格式转换
- Notepad++中设置Windows、Unix、Mac三种行尾换行符格式间的转换
- 如何在DOS/Windows和Linux/Unix之间进行文件格式转换
- 文档格式转换(win,unix\linux,mac)