Solved

Using grep

Posted on 2007-03-30
13
493 Views
Last Modified: 2013-12-06
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`
0
Comment
Question by:wemtz
  • 4
  • 2
  • 2
  • +3
13 Comments
 
LVL 25

Assisted Solution

by:Cyclops3590
Cyclops3590 earned 75 total points
Comment Utility
the -v switch
grep -v -i searchWord `find . -name *.xml -print`
0
 
LVL 84

Expert Comment

by:ozo
Comment Utility
find . | grep ^find:
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 100 total points
Comment Utility
grep -i searchWord `find . -name *.xml -print 2> /dev/null`
0
 
LVL 25

Expert Comment

by:Cyclops3590
Comment Utility
oops, misunderstood the question.  I read it quick and thought you were going for inverting the printed results.
0
 
LVL 19

Expert Comment

by:jools
Comment Utility
do you have permissions to access /directory/etc?
0
 

Author Comment

by:wemtz
Comment Utility
jools, do I have permission....NO.  I'm sure if I was root, maybe I could access all of the directories.
0
Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

 
LVL 19

Assisted Solution

by:jools
jools earned 75 total points
Comment Utility
So you don't want to see the errors?

Try;
grep -i searchWord `find . -name *.xml -print` 2>/dev/null
0
 
LVL 48

Assisted Solution

by:Tintin
Tintin earned 75 total points
Comment Utility
The more common way of writing this is

find . -name "*.xml" -exec grep -i searchWord {} \; 2>/dev/null
0
 
LVL 51

Accepted Solution

by:
ahoffmann earned 175 total points
Comment Utility
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
 
LVL 19

Expert Comment

by:jools
Comment Utility
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
 
LVL 19

Expert Comment

by:jools
Comment Utility
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
 

Author Comment

by:wemtz
Comment Utility
jools, I do not understand your request.  I will include everyone when I issue the points.
thanks
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Java performance on Solaris - Managing CPUs There are various resource controls in operating system which directly/indirectly influence the performance of application. one of the most important resource controls is "CPU".   In a multithreaded…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Get a first impression of how PRTG looks and learn how it works.   This video is a short introduction to PRTG, as an initial overview or as a quick start for new PRTG users.

743 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now