Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Grep Command help

Status
Not open for further replies.

pplearnunix46

Programmer
Joined
Jan 15, 2015
Messages
6
Location
US
Hi All,

I have a set of files with naming convention as filename.sh and filename_d.sh
Among these I am searching a pattern within the script where INSERT statement is used with _D as a tablename. But I dont want to display the filenames with filename_d.sh . I am trying grep by negating it with -v but unable to get the results. Below is the command I used.

grep -v *_d.sh | grep -i insert | grep -i _d| head

This command is giving me list of filenames with filename_d.sh too which I dont need. Please help.

Thank you.
 
Try this...

Code:
find . -name 'filename*.sh' ! -name '*_d.sh' -exec grep -iq 'insert .*_d' {} \; -print

That will print the filenames without '_d', that have an INSERT to a _D table in them.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top