Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
Get a virtual cloud desktop with the Linux distro that you want in less than five minutes with Shells! With over 10 pre-installed distros to choose from, the worry-free installation life is here! Whether you are a digital nomad or just looking for flexibility, Shells can put your Linux machine on the device that you want to use.
Exclusive for LQ members, get up to 45% off per month. Click here for more info.
|
|
07-29-2014, 04:27 AM
|
#1
|
LQ Newbie
Registered: Jun 2014
Posts: 2
Rep:
|
Explanation
Hello Every one, am a new bie to linux.
I need an explanation on this:
file / --user harry -exec cp -rfp {} /mkdir/file \;
Thanks.
|
|
|
07-29-2014, 04:33 AM
|
#2
|
Member
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
|
I think you put "file" where you should have put "find". And "--user" where you meant "-user".
Last edited by linosaurusroot; 07-29-2014 at 04:34 AM.
|
|
|
07-29-2014, 06:10 AM
|
#3
|
LQ Newbie
Registered: Jun 2014
Posts: 2
Original Poster
Rep:
|
Yes...sorry
It should be "find / -user harry -exec cp -rfp {} /mkdir/file \;
My question is i dont understand the exec option as well as the {} and the \ at the end,
and why is there ; to the end.
Thanks
|
|
|
07-30-2014, 03:58 PM
|
#4
|
LQ Newbie
Registered: Oct 2009
Distribution: Slackware 13
Posts: 17
Rep:
|
Hi
exec option is an execute instruction
{} is a placeholder for the file that was found
\; is the end of the command
basically find a file when file is found copy the file
rgs
|
|
|
07-30-2014, 04:11 PM
|
#5
|
LQ Guru
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573
|
The breakdown of that command is:
Find all files in "/" (and all of its subdirectories, aka: the entire filesystem) that belong to the user "harry". Each file that is found should be "cp -rfp"d to /mkdir/file.
So if three files are found:
/path/to/file1
/path/to/file2
/path/to/file3
Then three commands will be executed:
cp -rfp /path/to/file1 /mkdir/file
cp -rfp /path/to/file2 /mkdir/file
cp -rfp /path/to/file3 /mkdir/file
"{}" is just a shortcut telling exec "put the matching filename here". "\;" is the end of the exec command.
/mkdir/file is a VERY weird name for a directory though, are you sure that's right?
|
|
|
07-31-2014, 03:02 PM
|
#6
|
LQ 5k Club
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,311
Rep:
|
There's a website where you can get an explanation of long and/or complex commands:
http://explainshell.com/
Last edited by brianL; 07-31-2014 at 03:10 PM.
Reason: missed an h out, dozy bugger!
|
|
|
All times are GMT -5. The time now is 12:58 PM.
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|