The UNIX and Linux Forums  
Hello and Welcome from United States to the UNIX and Linux Forums! Thank You for Visiting and Joining Our Global Community.

Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google unix.com



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
Find and store files based on FileName and Modified Time edisonantus UNIX for Advanced & Expert Users 2 02-19-2008 02:25 PM
file moving based on file content melvyn.cochrane Shell Programming and Scripting 12 02-15-2008 06:10 AM
Adding filename into file content missutoomuch Shell Programming and Scripting 1 11-11-2005 04:02 PM
find the same content in the file ust UNIX for Dummies Questions & Answers 4 03-25-2005 05:55 AM
search for hardlinks based on filename via find command hunternjb UNIX for Dummies Questions & Answers 2 03-27-2001 01:07 AM

Closed Thread
English Japanese Spanish French German Portuguese Italian Dutch Swedish Russian Norwegian Hungarian Hebrew Danish Bulgarian Greek Powered by Powered by Google
 
LinkBack Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 06-01-2001
kollerj kollerj is offline
Registered User
  
 

Join Date: Jun 2001
Posts: 2
find filename based on file content

There is a flat file on my system which contains email addreses of people in my company. This file is utilized when sending notifications for various things. However nobody knows where this file is located or what it is named. The only thing we know is the email address of a user who needs to be deleted from this file. Is there a command to search through a file system and return results based on the content of the file? For example, if I wanted to see all filenames and locations where jkoller@jkoller.com was in the file how would I do that? Thanks!!!
  #2 (permalink)  
Old 06-01-2001
PxT's Avatar
PxT PxT is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2000
Location: Sacramento, CA
Posts: 909
Try this command:

find / -type f -exec grep email@host {} /dev/null \;
  #3 (permalink)  
Old 06-01-2001
kollerj kollerj is offline
Registered User
  
 

Join Date: Jun 2001
Posts: 2
THANK YOU! THAT WORKED!!
  #4 (permalink)  
Old 06-02-2001
kornshellmaven kornshellmaven is offline
Registered User
  
 

Join Date: Apr 2001
Posts: 25
Hey PxT,

The /dev/null is a nice twist - I'm not sure I understand why/how this works - I would have used a -l option on the grep to list the files. But showing the file & pattern found is nice.


Can you explain what this is doing? Is the behavior related to grep or to the find?

  #5 (permalink)  
Old 06-02-2001
PxT's Avatar
PxT PxT is offline Forum Advisor  
Registered User
  
 

Join Date: Oct 2000
Location: Sacramento, CA
Posts: 909
One of the features of grep is that if you specify more than one file to search it will show any matches prefixed by the filename. So I specify /dev/null as a second file to search. It will never match, and will always exist. You could really use any file, but /dev/null is a safe choice.
Closed Thread

Bookmarks

Tags
grep or

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On




All times are GMT -4. The time now is 12:26 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2009. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0