shellgreppipexargs

find and grep - Suppress terminated by signal 13


If I want to find only first match of command grep I use this:

find -name "*.jar" | xargs grep -al myText | head -1

And it's work just fine. But it's also show the next message:

xargs: grep: terminated by signal 13

Is it possible to suppress this message (to not show this message)?


Solution

  • Why do you have this error message?

    -> Signal 13 means a file is unreadable (bad permissions).

    2 solutions:

    1. Ignore this message (ugly)
    find -name "*.jar" | xargs grep -al myText 2>/dev/null | head -1
    
    1. Do not try to read unreadable file (better)
    find -name "*.jar" -readable | xargs grep -al myText | head -1
    

    Note:

    You could display unreadable files with this command:

    find \! -readable