The UNIX and Linux Forums  

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
returned from remote command Frank2004 HP-UX 2 04-30-2008 08:29 AM
Little bit weired : Find files in UNIX w/o using find or where command jatin.jain Shell Programming and Scripting 10 09-19-2007 03:47 AM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 02:38 PM
w/who command returned zero users sinyem UNIX for Advanced & Expert Users 6 10-21-2003 08:06 AM
Incorrect Exit Status Returned from FTP command - Help?? frustrated1 Shell Programming and Scripting 3 08-22-2003 12:25 AM

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 11-22-2006
Registered User
 

Join Date: Mar 2006
Posts: 14
Problem with files returned using Find command

When I enter the command below grep appears to be returning a file it shouldn't.

find . -name "*.*" -exec grep "testing" {} /dev/null \;
:tps3Mailfile
./SSI.ksh: # create TECHOUT dummy for test for testing purposes
./ftprimi1.ksh:# before running job in prod... change FTP to go to rimi instead of rad box(testing)
./pharm_alert.ksh:# send mail for testing, but not in prod

The file, tps3Mailfile does not contain the search string testing, why does this command continually pull this file? If I rerun the above using -type option instead of -name for the find command then the proper files are returned. Also, if you look at the path returned for this file it lists :tps3MailFile instead of ./tps3MailFile as one would expect.

Anyone have any ideas why this file is returned? If you use grep on this directory without the find command then the proper list of files is returned.

Thanks

D
Reply With Quote
Forum Sponsor
  #2 (permalink)  
Old 11-22-2006
Perderabo's Avatar
Unix Daemon
 

Join Date: Aug 2001
Location: Washington DC Area
Posts: 8,354
Quote:
Originally Posted by dfb500
If you use grep on this directory without the find command then the proper list of files is returned.
A directory is a file which contains entries and each entry is a filename and an inode number. I doubt that you really mean to run grep on a directory. Instead you mean to run grep on the files in a directory. These are two very different concepts. But your find statement is doing both of them. The current directory is . and it will match *.* and grep will open it and process it. Your output is odd, but directories are not ascii files. Try these commands:

grep testing .
grep testing . | od -c

and maybe you can get a handle on what exactly is happening.
Reply With Quote
  #3 (permalink)  
Old 12-10-2006
Registered User
 

Join Date: Dec 2006
Posts: 3
try this..

-exec is pretty inefficient.. use xargs. Try something like:

find . -type f | xargs grep "string"
Reply With Quote
  #4 (permalink)  
Old 12-11-2006
Registered User
 

Join Date: Dec 2006
Location: Maryland
Posts: 144
Yes ... make sure that grep is executed only on plain text files. So I would suggest

find /dirname -name 'blah' -type f -exec grep {} \;
Reply With Quote
Google UNIX.COM
Reply

Thread Tools
Display Modes




All times are GMT -7. The time now is 06:05 PM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited.
The UNIX and Linux Forums Content Copyright ©1993-2008 The CEP Blog All Rights Reserved -Ad Management by RedTyger Visit The Global Fact Book

Content Relevant URLs by vBSEO 3.2.0