zoukankan      html  css  js  c++  java
  • shell crlf to lf

    UNIX/Linux Commands

    You can use the following tools:

    • dos2unix (also known as fromdos) – converts text files from the DOS format to the Unix
      format
    • unix2dos (also known as todos) – converts text files from the Unix format to the DOS format.
    • sed – You can use sed command for same purpose
    • tr command
    • Perl one liner

    Task: Convert DOS file to UNIX format

    Type the following command to convert file called myfile.txt:
    $ dos2unix myfile.txt

    However above command will not make a backup of original file myfile.txt. To make a backup of original file. The original file is renamed with the original filename and a .bak extension. Type the following command:
    $ dos2unix -b myfile.txt

    Task: Convert UNIX file to DOS format

    Type the following command to convert file called myfile.txt:
    $ unix2dos myfile.txt
    $ unix2dos -b myfile.txt

    Task: Convert Dos TO Unix Using tr Command

    Type the following command:

    tr -d '
    ' < input.file > output.file

    Task: Convert Dos TO Unix Using Perl One Liner

    Type the following command:

    perl -pi -e 's/
    /
    /g' input.file

    Task: Convert UNIX to DOS format using sed command

    Type the following command if you are using bash shell:
    $ sed 's/$'"/`echo \ `/" input.txt > output.txt
    Note: sed version may not work under different UNIX/Linux variant,refer your local sed man page for more info.

    Task: Convert DOS newlines (CR/LF) to Unix format using sed command

    If you are using BASH shell type the following command (press Ctrl-V then Ctrl-M to get pattern or special symbol)
    $ sed 's/^M$//' input.txt > output.txt
    Note: sed version may not work under different UNIX/Linux variant, refer your local sed man page for more info.

  • 相关阅读:
    ibatis集成封装之路(to mysql)
    设计模式第一弹—适配器模式
    markdown语法
    outlook vba开发要点
    PHP中json_encode中文编码的问题_学习
    isset、empty、var==null、is_null、var===null详细理解
    对冒泡和二分法,特别是二分法有了更深的理解
    php Socket表单提交学习一下
    php Socket模拟表单上传文件函数_学习
    java第九节 网络编程的基础知识
  • 原文地址:https://www.cnblogs.com/kakaisgood/p/10418268.html
Copyright © 2011-2022 走看看