Find files that contain BOM headers under Linux and clear BOM header commands 2014-08-16 12:30:50

Source: Internet
Author: User
Find files that contain BOM headers under Linux and clear BOM header commands 2014-08-16 12:30:50

Classification: System operation and Maintenance

Locate the file that contains the BOM header, as follows:

Click ( here) to collapse or open

  1. Grep-r-i-l $ ' ^\xef\xbb\xbf '.
\XEF\XBB\XBF is a 16 binary representation of the UTF8 BOM
This command removes the BOM header from the current directory and all subdirectories.

Click ( here) to collapse or open

  1. Find. -type f-exec sed-i ' s/\xef\xbb\xbf//' {} \;

Another way:

Click ( here) to collapse or open

  1. Echo-ne ' \xef\xbb\xbf123456 ' | awk ' {if (nr==1) sub (/^\xef\xbb\xbf/, ""); print} '


Detailed explanation of BOM
Http://www.cnblogs.com/chengmo/archive/2010/10/30/1864004.html

Find files that contain BOM headers under Linux and clear BOM header commands 2014-08-16 12:30:50

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.