find and grep - Suppress terminated by signal 13

38 views Asked by At

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)?

1

There are 1 answers

0
Arnaud Valmary On BEST ANSWER

Why do you have this error message?

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

2 solutions:

  1. Ignore this message (ugly)
  • Add 2>/dev/null after xargs command
find -name "*.jar" | xargs grep -al myText 2>/dev/null | head -1
  1. Do not try to read unreadable file (better)
  • Add a condition -readable (readable by current user) to find command
find -name "*.jar" -readable | xargs grep -al myText | head -1

Note:

You could display unreadable files with this command:

find \! -readable