Solved

linux help

Posted on 2009-04-14
17
217 Views
Last Modified: 2012-05-06
HI,

pls tell me what this comand exactly will do step by step

find  /etc/  -name docecot.pem  -exec  rm { }  \;


Thanks
0
Comment
Question by:mastdesi
  • 8
  • 4
  • 3
  • +1
17 Comments
 
LVL 29

Expert Comment

by:fosiul01
ID: 24143031
from my understanding
it will find dovecot.pem in /etc/ directory and will delete this file
0
 

Author Comment

by:mastdesi
ID: 24143050
TY

even i guess this too but what does  { }  \; means at the end of line
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24143066
omm i just tested this command , it delete the file

but i dont know exactly what {} \; do, let me have a look on net
0
 

Author Comment

by:mastdesi
ID: 24143084
k..bro :-)
0
 
LVL 48

Accepted Solution

by:
Tintin earned 50 total points
ID: 24143138
find /etc  (start searching from the /etc directory and descend to all subdirectories)

-name docote.pem  (match any file called docote.pem

-exec rm {} \;  (exec the rm command, ie: delete any matched files, where the {} is substituted by the current matched filename)

\;  (terminate the exec argument)
0
 
LVL 84

Expert Comment

by:ozo
ID: 24143143
man find
     -exec utility [argument ...];
             True if the program named utility returns a zero value as its
             exit status.  Optional arguments may be passed to the utility.
             The expression must be terminated by a semicolon (``;'').  If the
             string ``{}'' appears anywhere in the utility name or the argu-
             ments it is replaced by the pathname of the current file.
             Utility will be executed from the directory from which find was
             executed.  Utility and arguments are not subject to the further
             expansion of shell patterns and constructs.
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24143145
ok this could be true

-exec  rm { }  \;  = its executing rm command ....
0
 

Author Comment

by:mastdesi
ID: 24143241
So may i know final thoughts from u experts about
-exec  rm { }  \;

i still didnt get it properly ;-(
0
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
LVL 48

Expert Comment

by:Tintin
ID: 24143249
What part of it don't you get?  Was my explanation useful at all?
0
 
LVL 29

Expert Comment

by:fosiul01
ID: 24143270
I think @tintin gave a proper solution which is


find  /etc/  -name docecot.pem    = is finding the file

 -exec  rm   = executing the rm command

{ }  \;   = what this command  (find  /etc/  -name docecot.pem )  find the output, its deleting that file

normaly we use

rm -rf somedirectory
here some directory is replacing by  { } \;

0
 

Author Comment

by:mastdesi
ID: 24143381
Thanks all
so that means if i put {}  \: at the end of any line like find /  -name .bash*  -exec {}  \;  it will remove any output of find command?..it looks very cool
0
 

Author Closing Comment

by:mastdesi
ID: 31570181
ty bro :-)
0
 
LVL 84

Expert Comment

by:ozo
ID: 24143425
no, -exec {}  \; would try to execute the filename as a command
-exec rm {}  \; would try to execute the rm command with the filename as the argument
0
 

Author Comment

by:mastdesi
ID: 24143504
thank u very much ozo for explanation :-)
0
 
LVL 48

Expert Comment

by:Tintin
ID: 24143534
Note that the {} \; syntax is specific to the find command.  The only other command I can think of that has a similar construct is xargs.
0
 

Author Comment

by:mastdesi
ID: 24143613
ok kindly all expert reply to my this question too if possible
http://www.experts-exchange.com/OS/Linux/Q_24322530.html

thanks all
0
 

Author Comment

by:mastdesi
ID: 24143652
sorry i just solved that question myself...
0

Featured Post

Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

Join & Write a Comment

Suggested Solutions

If you have a server on collocation with the super-fast CPU, that doesn't mean that you get it running at full power. Here is a preamble. When doing inventory of Linux servers, that I'm administering, I've found that some of them are running on l…
Join Greg Farro and Ethan Banks from Packet Pushers (http://packetpushers.net/podcast/podcasts/pq-show-93-smart-network-monitoring-paessler-sponsored/) and Greg Ross from Paessler (https://www.paessler.com/prtg) for a discussion about smart network …
In a previous video, we went over how to export a DynamoDB table into Amazon S3.  In this video, we show how to load the export from S3 into a DynamoDB table.
This demo shows you how to set up the containerized NetScaler CPX with NetScaler Management and Analytics System in a non-routable Mesos/Marathon environment for use with Micro-Services applications.

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now