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 12:29 PM
Little bit weired : Find files in UNIX w/o using find or where command jatin.jain Shell Programming and Scripting 10 09-19-2007 07:47 AM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 06:38 PM
w/who command returned zero users sinyem UNIX for Advanced & Expert Users 6 10-21-2003 12:06 PM
Incorrect Exit Status Returned from FTP command - Help?? frustrated1 Shell Programming and Scripting 3 08-22-2003 04:25 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 11-22-2006
dfb500 dfb500 is offline
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
  #2 (permalink)  
Old 11-23-2006
Perderabo's Avatar
Perderabo Perderabo is offline Forum Staff  
Unix Daemon
  
 

Join Date: Aug 2001
Location: Ashburn, Virginia
Posts: 9,126
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.
  #3 (permalink)  
Old 12-10-2006
johnnyk johnnyk is offline
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"
  #4 (permalink)  
Old 12-12-2006
kapilraj kapilraj is offline
Registered User
  
 

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

find /dirname -name 'blah' -type f -exec grep {} \;
Closed Thread

Bookmarks

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 01:06 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