How do you search for files containing DOS line endings (CRLF) with grep on Linux?

后端 未结 9 1232
栀梦
栀梦 2020-11-30 17:24

I want to search for files containing DOS line endings with grep on Linux. Something like this:

grep -IUr --color \'\\         


        
9条回答
  •  天命终不由人
    2020-11-30 18:18

    dos2unix has a file information option which can be used to show the files that would be converted:

    dos2unix -ic /path/to/file
    

    To do that recursively you can use bash’s globstar option, which for the current shell is enabled with shopt -s globstar:

    dos2unix -ic **      # all files recursively
    dos2unix -ic **/file # files called “file” recursively
    

    Alternatively you can use find for that:

    find -exec dos2unix -ic {} +            # all files recursively
    find -name file -exec dos2unix -ic {} + # files called “file” recursively
    

提交回复
热议问题