Using grep

Might you know the Unix command that "would not display" the directories for which the following grep command, shows "find: cannot open /directory/etc"

This is my grep command:
grep -i searchWord `find . -name *.xml -print`
wemtzAsked:
Who is Participating?

[Webinar] Streamline your web hosting managementRegister Today

x
 
ahoffmannConnect With a Mentor Commented:
Tintin's suggestion improved to work on any shell on any *x ;-)
sh -c 'find . -type f -name "\*.xml" -exec grep -i searchWord {} \; 2>/dev/null'
0
 
Cyclops3590Connect With a Mentor Commented:
the -v switch
grep -v -i searchWord `find . -name *.xml -print`
0
 
ozoCommented:
find . | grep ^find:
0
Never miss a deadline with monday.com

The revolutionary project management tool is here!   Plan visually with a single glance and make sure your projects get done.

 
ozoConnect With a Mentor Commented:
grep -i searchWord `find . -name *.xml -print 2> /dev/null`
0
 
Cyclops3590Commented:
oops, misunderstood the question.  I read it quick and thought you were going for inverting the printed results.
0
 
joolsCommented:
do you have permissions to access /directory/etc?
0
 
wemtzAuthor Commented:
jools, do I have permission....NO.  I'm sure if I was root, maybe I could access all of the directories.
0
 
joolsConnect With a Mentor Commented:
So you don't want to see the errors?

Try;
grep -i searchWord `find . -name *.xml -print` 2>/dev/null
0
 
TintinConnect With a Mentor Commented:
The more common way of writing this is

find . -name "*.xml" -exec grep -i searchWord {} \; 2>/dev/null
0
 
joolsCommented:
Sorry Guys, I just reread and saw ozo's answer! I didn't see it before honest!

I don't mind if points are changed (if thats possible!)

Just in case you were wondering the 2> redirects all errors (stderr), in this case it sends them to null (think trash).

J
0
 
joolsCommented:
Thanks,

Apologies wemtz, you may have missed the ozo response as well, would you please be so kind as to regrade, I won't moan again.

Cheers All.
0
 
wemtzAuthor Commented:
jools, I do not understand your request.  I will include everyone when I issue the points.
thanks
0
All Courses

From novice to tech pro — start learning today.