How to check if the file is a binary file and read all the files which are not?

后端 未结 13 864
走了就别回头了
走了就别回头了 2020-12-05 16:58

How can I know if a file is a binary file?

For example, compiled c file.

I want to read all files from some directory, but I want ignore binary files.

相关标签:
13条回答
  • 2020-12-05 17:49

    I use

    ! grep -qI . $path
    

    Only drawback I can see is that it will consider an empty file binary but then again, who decides if that is wrong?

    0 讨论(0)
提交回复
热议问题