![]() |
|
|
google unix.com
|
|||||||
| Forums | Register | Forum Rules | Links | Albums | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read |
| UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !! |
More UNIX and Linux Forum Topics You Might Find Helpful
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| What is the Best way to search files for a string?? | 35Soinc | UNIX for Dummies Questions & Answers | 15 | 03-25-2008 04:34 PM |
| Search a string from list of input files | sivakumarvenkat | UNIX for Dummies Questions & Answers | 2 | 03-08-2006 06:08 PM |
| Search files for a string in the remote machine | a_rivu | UNIX for Dummies Questions & Answers | 2 | 06-14-2005 03:31 PM |
| I dont want to know any search engines | memattmyself | Shell Programming and Scripting | 1 | 05-09-2002 12:09 PM |
| Search all files for specific string | sureshy | UNIX for Dummies Questions & Answers | 4 | 03-06-2002 12:28 PM |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
||||
|
How do I search for files that dont contain a certain string? I am currently trying
find ./logs -size +1c -exec grep -l 'Process Complete' {} \; -exec ls -l {} \; > $TOD Which gives me files that are reater han 0 file size and contain the string 'Process complete' but I want files that DONT contain Process Complete. If i use the -v option for grep it still doesnt work! |
|
||||
|
This doesnt seem to be working as it is still picking up the files with Process Complete in them. I have tried moving the ! around but still no joy. 'Process Complete' should only be on the last line of the file if that helps.
Last edited by tonydsam; 05-05-2004 at 04:26 AM.. |
|
|||||
|
I think that your problem is that you are using find to grep on the ./logs directory itself and not just on the files in that directory. You need to restrict the find to only grep within plain files.
Lets test this theory, using some test files... $ mkdir logs $ echo 'Process Complete' > logs/log1 $ echo 'otherwise' > logs/log2 ...first find files that do contain the string... $ find ./logs -size +1c -exec grep -q 'Process Complete' {} \; -print ./logs/log1 ...as expected. Now find files that do NOT contain the string... $ find ./logs -size +1c ! -exec grep -q 'Process Complete' {} \; -print ./logs ./logs/log2 ...woah! What's that "./logs" thing doing there?! If I was using "-exec ls -l {} \;" then it would return every file in the directory! Better restrict the find to plain files... $ find ./logs -type f -size +1c ! -exec grep -q 'Process Complete' {} \; -print ./logs/log2 ...OK! |
|
|||||
|
Quote:
![]() Thank you! For me, I wanted to find any instance of our "old" domain name, while EXCLUDING email addresses. Finally! Code:
find . -type f ! -exec grep -q '@olddomain.com' {} \; -exec grep -q 'olddomain.com' {} \; -print
|
![]() |
| Bookmarks |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|