Find and remove DOS line endings on Ubuntu

前端 未结 7 1516
攒了一身酷
攒了一身酷 2021-01-04 11:37

I have found that many of my files have DOS line endings. In VI they look like this: \"^M\". I don\'t want to modify files that don\'t have these DOS line endings. How do

7条回答
  •  醉话见心
    2021-01-04 12:22

    you can use the command:

       dos2ux file.in>file.out or:
    

    in perl:

    perl -pi -e 's/\r//g' your_file
    

    alternatively you can do:

    • open in vi
    • go to command mode
    • type :%s/[ctrl-V][CTRL-M]//g

提交回复
热议问题