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
question on find and remove command arunkumar_mca UNIX for Dummies Questions & Answers 1 12-10-2007 09:54 PM
question about find command hnhegde UNIX for Dummies Questions & Answers 4 10-26-2006 12:00 PM
how to find a file named vijay in a directory using find command amirthraj_12 UNIX for Dummies Questions & Answers 5 10-25-2006 02:39 PM
Find command question negixx Shell Programming and Scripting 6 07-08-2005 08:43 AM
command find returned bash: /usr/bin/find: Argument list too long yacsil Shell Programming and Scripting 1 12-15-2003 02:38 PM

Closed Thread
 
Submit Tools LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-06-2002
Registered User
 

Join Date: Sep 2001
Posts: 114
Stumble this Post!
'find' command question

my solaris text talks about the 'find' command... it further goes to talk about an "action" used with the find command.

I am completely confused as to what the {} do with the find comand.

the explanation is this: "A set of braces, {}, delimits where the file name is passed to the command from the prceding expressions."

Now what does this mean? It makes no sense to me.

an example they give is the following:

$ find ~ -name core -exec rm {} \;
Forum Sponsor
  #2 (permalink)  
Old 03-06-2002
TioTony's Avatar
Bit Pusher
 

Join Date: Oct 2001
Location: Southern California
Posts: 332
Stumble this Post!
Basically it just means find is going to pass the files it found to what ever command you specify. In your example, find going to locate core files and send them as output to the rm command. It's just a fancy way to find stuff and delete it at the same time.
  #3 (permalink)  
Old 03-07-2002
Registered User
 

Join Date: Nov 2001
Location: New Zealand
Posts: 333
Stumble this Post!
Just answer your question about the {} braces.....

The braces become the result set from the find command....... so your rm {} will effectively do a "rm /dira/cor /dirb/core /dirc/core"

Replacing the {} with all returned arguments from the find query. So for example if you wanted to cp the result of your search to a certain directory you could use:

find . -name my_file -exec cp {} /export/home/all_my_files/ \;

This would copy the file it found on the file system to your specified directory. Obviously for this you could only do it for a single return.....as if find retrieves multiple instances (as with your core search) then you'd be in a world of pain.

If you want multiple things to be done...i.e. renaming the result files then you'd use the xargs command (RTM).
__________________
Pete
Google The UNIX and Linux Forums
Closed Thread

Thread Tools
Display Modes




All times are GMT -7. The time now is 04:37 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