Solved

linux help

Posted on 2009-04-14
17
220 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
Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

 

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

Secure Your Active Directory - April 20, 2017

Active Directory plays a critical role in your company’s IT infrastructure and keeping it secure in today’s hacker-infested world is a must.
Microsoft published 300+ pages of guidance, but who has the time, money, and resources to implement? Register now to find an easier way.

Question has a verified solution.

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

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…
Every server (virtual or physical) needs a console: and the console can be provided through hardware directly connected, software for remote connections, local connections, through a KVM, etc. This document explains the different types of consol…
Learn how to find files with the shell using the find and locate commands. Use locate to find a needle in a haystack.: With locate, check if the file still exists.: Use find to get the actual location of the file.:
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.

713 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