Solved

linux help

Posted on 2009-04-14
17
219 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
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 

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

Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

Question has a verified solution.

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

Using 'screen' for session sharing, The Simple Edition Step 1: user starts session with command: screen Step 2: other user (logged in with same user account) connects with command: screen -x Done. Both users are connected to the same CLI sessio…
SSH (Secure Shell) - Tips and Tricks As you all know SSH(Secure Shell) is a network protocol, which we use to access/transfer files securely between two networked devices. SSH was actually designed as a replacement for insecure protocols that sen…
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.:
Learn how to navigate the file tree with the shell. Use pwd to print the current working directory: Use ls to list a directory's contents: Use cd to change to a new directory: Use wildcards instead of typing out long directory names: Use ../ to move…

773 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