博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
[Ubuntu] Remove Byte Order Mark (BOM) from files recursively [Forward article]
阅读量:7196 次
发布时间:2019-06-29

本文共 1627 字,大约阅读时间需要 5 分钟。

Original article: http://www.yiiframework.com/wiki/570/remove-byte-order-mark-bom-from-files-recursively/

 

The problem was that all my web applications ran normally on localhost, but on server the Greek characters (or any other no-english characters) displayed with problems.

So, I needed to remove BOM from hundreds view files of Yii from a lot of Yii projects manually. Netbeans has an option to keep files Encoding in utf-8 but not utf-8 without BOM.

My previous solution was the converting in utf-8 without BOM encoding one by one file on notepad++ consuming a lot of my time!

Many servers has not this issue but for other servers this is important. So, after of two hours searching I found a fast way to do that by commands.

(If you have windows, install cygwin first)

1) Open a shell command, go into your root folder that contains the project

2) Run this command

grep -rl $'\xEF\xBB\xBF'  /home/rootfolder/Yii_project  > file_with_boms.txt

3) Now, Run this one

while read l; do sed -i '1 s/^\xef\xbb\xbf//'  $l; done < file_with_boms.txt

Thats it! The BOM will be removed from all files that contained it. Now you can upload your project on your server.

Note: Because I didn't use this way many times and I don't know if it works properly for all cases and files, make first a backup of your project! :)

 

 

shell script for replacing tab with spaces and remove bom head from file.

find /path/to/your/folder -type f -exec sed -i 's/\t/    /g' {} \; && grep -rl $'\xEF\xBB\xBF'  /path/to/your/folder  > file_with_boms.txt && while read l; do sed -i '1 s/^\xef\xbb\xbf//'  $l; done < file_with_boms.txt && rm file_with_boms.txt

 

转载地址:http://vgvkm.baihongyu.com/

你可能感兴趣的文章
oracle 存储过程详细介绍(创建,删除存储过程,参数传递等)
查看>>
textview第一次出现不可滚动文本,但是点击出现键盘,键盘落下,就可以滚动问题...
查看>>
Android小感悟-重写textview组件感悟
查看>>
bnu Game 博弈。
查看>>
【转】IntelliJ IDEA2016.1 + maven 创建java web 项目
查看>>
微软宣布支持基于虚拟机的Azure IOT Edge服务
查看>>
以流动债务为例论指标的合理使用
查看>>
保Cloudera弃Hortonworks,新平台将支持五大云供应商
查看>>
一文教会你数据库性能调优(附某大型医院真实案例)
查看>>
Android - 关于设备版本号
查看>>
听说你Binder机制学的不错,来面试下这几个问题(一)
查看>>
前端测试:Part II (单元测试)
查看>>
ssh整合问题总结--运行项目时报java.lang.StackOverflowError(堆栈溢出)异常
查看>>
.NET中的repeater简介及分页效果
查看>>
基于MVP架构设计ASP.Net的应用研究
查看>>
在Linux系统中安装LNMP出现的错误总结
查看>>
9.4. import your signed certificate
查看>>
4.3. Module
查看>>
【云栖大会】AliOS Things宣布开源,支持物联网设备快速上云
查看>>
TensorFlow学习笔记之三——适合入门的一些资源
查看>>