Solved

linux help

Posted on 2009-04-14
17
218 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
Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Fixing Non-Standard characters in text 8 92
nagios remote hosts 9 46
How to find Linux Server's last patch date 9 37
Linux Copy Command - All Files inc Directory 1 32
Little introduction about CP: CP is a command on linux that use to copy files and folder from one location to another location. Example usage of CP as follow: cp /myfoder /pathto/destination/folder/ cp abc.tar.gz /pathto/destination/folder/ab…
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 several ways to interact with files and get file information from the bash shell. ls lists the contents of a directory: Using the -a flag displays hidden files: Using the -l flag formats the output in a long list: The file command gives us mor…
Connecting to an Amazon Linux EC2 Instance from Windows Using PuTTY.

867 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

20 Experts available now in Live!

Get 1:1 Help Now