image
image

Go Back   macosx.com > Mac Help Forums > Unix & X11

Reply
 
Thread Tools
  #1  
Old December 11th, 2004, 04:36 PM
Registered User
 
Join Date: Mar 2001
Location: Groton, CT, USA
Posts: 1,291
Thanks: 0
Thanked 0 Times in 0 Posts
chemistry_geek is on a distinguished road
Searching for text inside of a file using grep.

I'm trying to search for text inside all files in deep subdirectories on an external hard drive. I've read the man page for grep but I still can't seem to get Panther to find the files I'm looking for. When I place the file I eventually found on my desktop, grep finds the file without any problems. Any suggestions?
Reply With Quote
  #2  
Old December 11th, 2004, 04:54 PM
ElDiabloConCaca's Avatar
U.S.D.A. Prime
 
Join Date: Aug 2001
Location: San Antonio, Texas
Posts: 10,380
Thanks: 3
Thanked 124 Times in 113 Posts
ElDiabloConCaca is a jewel in the roughElDiabloConCaca is a jewel in the roughElDiabloConCaca is a jewel in the rough
What's the exact command you're using?

It sounds like you're not specifying the correct search path -- like you're just searching in subfolders of your home folder.
__________________
Power Macintosh G4/500MHz "Yikes!" 10.4.11 Server • 1024MB • 3 x 120GB + 320GB • DVR-111D • 2 x Radeon 7000 PCI • 2 x 17" CRT
MacBook 2.0GHz Core 2 Duo - White 10.5.5 • 2048MB • 80GB • CD-RW/DVD-ROM
iPod Photo 60GB • iPod nano 1GB • AT&T DSL 6Mb/768k
http://www.jeffhoppe.com
Reply With Quote
  #3  
Old December 12th, 2004, 12:03 PM
Registered User
 
Join Date: Mar 2001
Location: Groton, CT, USA
Posts: 1,291
Thanks: 0
Thanked 0 Times in 0 Posts
chemistry_geek is on a distinguished road
This correctly finds the file when the it is on my desktop:

grep -l "0.136" /Users/chemgeek/Desktop/*.*

I have tried these and they do not find the file I needed:

grep -r "0.136" /Volumes/LaCie\ Disk/chemgeek/Documents/9-28-04/Masters_Thesis_Chemistry/Chemical_Structures/*.*

grep -l "0.136" /Volumes/LaCie\ Disk/chemgeek/Documents/9-28-04/Masters_Thesis_Chemistry/Chemical_Structures/*.*


The hard drive the files are stored on is a LaCie Big Disk Extreme 320GB.
http://www.lacie.com/products/product.htm?pid=10489

Last edited by chemistry_geek; December 12th, 2004 at 12:10 PM.
Reply With Quote
  #4  
Old December 12th, 2004, 12:47 PM
chevy's Avatar
Leopardo Da Vinci
 
Join Date: Nov 2001
Location: Inside the black box, CH
Posts: 3,831
Thanks: 0
Thanked 0 Times in 0 Posts
chevy is on a distinguished road
did you try
grep -lr "0.136" /Volumes/LaCie\ Disk/chemgeek/Documents/9-28-04/Masters_Thesis_Chemistry/Chemical_Structures/*.*
?
__________________
My current machine is an iMac Core 2 Duo 2.16 GHz 24" with MacOS X 10.5. My Apples are here. My oldest Apple was born in 1977.
GS/P/>SS d-(++) s+: a+ C+(C) U* P L+ E--- W++ N- o+ K? w O-- M++ V PS+ PE+ Y- PGP t+ 5 X+ R tv-- b+++ DI++ D+ G e+++ h---- r+++ y?
Time is not changing, I'm just traveling through time.
Reply With Quote
  #5  
Old December 12th, 2004, 04:59 PM
Registered User
 
Join Date: Mar 2001
Location: Groton, CT, USA
Posts: 1,291
Thanks: 0
Thanked 0 Times in 0 Posts
chemistry_geek is on a distinguished road
yes, I tried that too; it did not work.
Reply With Quote
  #6  
Old December 12th, 2004, 06:46 PM
scruffy's Avatar
Notorious Olive Counter
 
Join Date: Dec 2000
Location: Soviet Canuckistan
Posts: 1,726
Thanks: 0
Thanked 0 Times in 0 Posts
scruffy is on a distinguished road
If you're doing a recursive search, you shouldn't need to specify *.* - in fact, I think that might only look at subdirectories that have a dot in their names.

If you specify the exact file name, rather than a globbing pattern, does it find it? what is the filename? what is its format (what if you added the -a option to make it treat binary files as text?)
__________________

What is the robbing of a bank compared to the founding of a bank?
-- Bertold Brecht
Reply With Quote
  #7  
Old December 14th, 2004, 08:21 AM
Registered User
 
Join Date: Mar 2001
Location: Groton, CT, USA
Posts: 1,291
Thanks: 0
Thanked 0 Times in 0 Posts
chemistry_geek is on a distinguished road
OK, I think I know why grep -lr "0.136" /Volumes/LaCie\ Disk/chemgeek/Documents/9-28-04/Masters_Thesis_Chemistry/Chemical_Structures/*.* didn't find the file the day I was searching for it. I had not yet updated the locate database. After I ran the daily and weekly system maintenance cron jobs, grep -lr "0.136" /Volumes/LaCie\ Disk/chemgeek/Documents/9-28-04/Masters_Thesis_Chemistry/Chemical_Structures/*.* found three files in less than one second, literally.

Thank you all for your help and suggestions. I very much appreciate all the help I get from the members here.
Reply With Quote
  #8  
Old December 14th, 2004, 08:43 AM
Registered User
 
Join Date: Mar 2001
Location: Groton, CT, USA
Posts: 1,291
Thanks: 0
Thanked 0 Times in 0 Posts
chemistry_geek is on a distinguished road
Quote:
Originally Posted by scruffy
If you're doing a recursive search, you shouldn't need to specify *.* - in fact, I think that might only look at subdirectories that have a dot in their names.

If you specify the exact file name, rather than a globbing pattern, does it find it? what is the filename? what is its format (what if you added the -a option to make it treat binary files as text?)

The reason I was looking for a specific text pattern inside all of the files for my masters thesis is because I forgot the specific file name and folder(s) it could have been placed in. I remember the the text that was in the file, that's why I was using grep. The file I was looking for was a ChemDraw file that contains both binary and text information. When viewed in BBEdit, I see "gibberish" characters everywhere and a few places with text that I entered to explain a chemical reaction.
Reply With Quote
Reply

Thread Tools

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 Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off
Forum Jump


All times are GMT -5. The time now is 10:57 PM.


Mac Support® Version 3.7.2
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.1.0
Copyright 2000-2008 DigitalCrowd, Inc.