Tuesday, May 21, 2024
1
rated 0 times [  1] [ 0]  / answers: 1 / hits: 763  / 2 Years ago, fri, november 11, 2022, 2:00:20

I cannot find the reason why grep cannot find the file with the word 'coomunities'. I used


grep -ril --include=GLOB "coomunities"  .

Note: communities is on purpose mispelled.
The file is a docx and currently has permissions '-rwxrwxrwx'. I tried



  • run from the same folder or other folder

  • changed permission to file

  • tried a different words for the same file (Ubuntu, linux, literacy)

  • include specifically docx extension

  • I tried the GUI of searchmonkey which can find the file correctly
    still the file seems not appearing in any search using grep. Any idea?


More From » command-line

 Answers
2

Few issues.



  1. You Can't grep a docx file. Grep works with standard output files or text. Docx is encoded
    Take a look at this
    How to search multiple DOCX files for a string within a Word field?
    A quick way to verify this is to cat <file>.docx and see if what come out is readable or not.



  2. Outside of the docx issue. I haven't used GLOB in grep, but my understanding is that it is pretty limited. Your better off using regex. Something like this


    grep -Ei "coom[^[:space:]]+" *.<File Ext>



  3. Personally when I can't find something I know should be there, I change the needle, not the haystack. Try "coom" or even "coo".



  4. I don't think permission are the issue. Run the cat command, if you can read it then you don't need to change permission for grep.




Hope that helps.


[#305] Saturday, November 12, 2022, 2 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hreadsoplet

Total Points: 220
Total Questions: 108
Total Answers: 105

Location: Serbia
Member since Fri, Jun 3, 2022
2 Years ago
hreadsoplet questions
;