How to grep a text file which contains some binary data?

后端 未结 11 1687
遇见更好的自我
遇见更好的自我 2020-11-30 19:48

grep returns

Binary file test.log matches

For example

echo    \"line1 re \\x00\\r\\nline2\\r\\nline3 re\\r\\n\" > test.log  # in zsh         


        
11条回答
  •  青春惊慌失措
    2020-11-30 20:07

    As James Selvakumar already said, grep -a does the trick. -a or --text forces Grep to handle the inputstream as text. See Manpage http://unixhelp.ed.ac.uk/CGI/man-cgi?grep

    try

    cat test.log | grep -a somestring
    

提交回复
热议问题