Solved

linux help

Posted on 2009-04-14
17
221 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 

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
 
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction We as admins face situation where we need to redirect websites to another. This may be required as a part of an upgrade keeping the old URL but website should be served from new URL. This document would brief you on different ways ca…
Setting up Secure Ubuntu server on VMware 1.      Insert the Ubuntu Server distribution CD or attach the ISO of the CD which is in the “Datastore”. Note that it is important to install the x64 edition on servers, not the X86 editions. 2.      Power on th…
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.
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Suggested Courses

751 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