Register FAQ / Rules Forum Spy Search Today's Posts Mark Forums Read
Go Back   MacRumors Forums > Archive > Archives of Old Posts > Mac Help/Tips

 
 
Thread Tools Search this Thread Display Modes
Old Dec 19, 2002, 09:43 AM   #1
zimv20
macrumors 601
 
zimv20's Avatar
 
Join Date: Jul 2002
Location: chicago
unix: odd behavior w/ 'find' command

the other day i tried running a certain construct of the find command, via command line, but it didn't work:

Code:
% find . -type f -exec grep foo {}\; -print
it just sat there, never returned (even on my very small test case). i've used this construct for years, so i know that it works (on some or most unix implementations, anyway).

i was able to find a workaround (for those interested):

Code:
% find . -type f -print | xargs grep foo
(sadly, the workaround doesn't work all the time, as xargs was choking on something coming through the pipe and had to restrict its running to a subdir)

any unix heads know what's up w/ the first find? has 'find' changed since i was doing all my unix coding?

i'm running 10.2.2, if that matters.
__________________
Oct 2011: check out my band's first album @ boxsetauthentic.com
zimv20 is offline   0
Old Dec 19, 2002, 12:43 PM   #2
Doctor Q
macrumors god
 
Doctor Q's Avatar
 
Join Date: Sep 2002
Location: Blood Donation Center
May I ask what the purpose of the command is? Maybe you don't need the -print option if you use other grep switches, e.g.,

% find . -type f -exec grep -l foo {} \;
__________________
I support the MacRumors Blood Drive!
Doctor Q is offline   0
Old Dec 19, 2002, 11:51 PM   #3
zimv20
Thread Starter
macrumors 601
 
zimv20's Avatar
 
Join Date: Jul 2002
Location: chicago
Quote:
Originally posted by Doctor Q
May I ask what the purpose of the command is? Maybe you don't need the -print option if you use other grep switches, e.g.,

% find . -type f -exec grep -l foo {} \;
i believe the print lets me know in which file the grep hit is in.

does this work on your machine?

oh -- the purpose is to search a subdir for files containing the string "foo". well, okay, i was searching for "smtp." but you get the idea.
__________________
Oct 2011: check out my band's first album @ boxsetauthentic.com
zimv20 is offline   0
Old Dec 20, 2002, 09:15 PM   #4
Doctor Q
macrumors god
 
Doctor Q's Avatar
 
Join Date: Sep 2002
Location: Blood Donation Center
Yes, the find command that I suggested works for me - to display the names of files in the current directory or any subdirectory, recursively, that contains the string "foo". The -l switch of the grep command means "display filename instead of displaying the matching line".

Please note that a space before the \; is required, as in the example I gave.
__________________
I support the MacRumors Blood Drive!
Doctor Q is offline   0
Old Dec 21, 2002, 12:04 AM   #5
zimv20
Thread Starter
macrumors 601
 
zimv20's Avatar
 
Join Date: Jul 2002
Location: chicago
Quote:
Originally posted by Doctor Q

Please note that a space before the \; is required, as in the example I gave.
DOH!

that's it. thank you. gee, i actually knew unix once upon a time...
__________________
Oct 2011: check out my band's first album @ boxsetauthentic.com
zimv20 is offline   0

 
MacRumors Forums > Archive > Archives of Old Posts > Mac Help/Tips

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

Forum Jump

Similar Threads
thread Thread Starter Forum Replies Last Post
Disappearing Folders, Files & Other Odd Behavior nygladiator2008 Mac OS X 2 Aug 5, 2008 04:00 AM
3G sync question - odd behavior jsgreen iPhone Tips, Help and Troubleshooting 0 Jul 28, 2008 01:17 PM
Odd behavior, blue hue over the screen when switching users? BiikeMike MacBook Pro 5 Mar 25, 2008 05:11 PM
OSX Tiger odd behavior after crash TheBrazilianGuy Mac OS X 2 Mar 3, 2008 01:26 PM
cingular razr odd behavior w/ headset Sean7512 Community Discussion 0 Jul 31, 2006 10:14 PM


All times are GMT -5. The time now is 07:13 AM.

Mac Rumors | Mac | iPhone | iPhone Game Reviews | iPhone Apps

Mobile Version | Fixed | Fluid | Fluid HD
Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2013, Jelsoft Enterprises Ltd.

Privacy / DMCA contact / Affiliate and FTC Disclosure
Copyright 2002-2013, MacRumors.com, LLC