LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 07-29-2014, 03:27 AM   #1
FaisalSeif
LQ Newbie
 
Registered: Jun 2014
Posts: 2

Rep: Reputation: Disabled
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.
 
Old 07-29-2014, 03:33 AM   #2
linosaurusroot
Member
 
Registered: Oct 2012
Distribution: OpenSuSE,RHEL,Fedora,OpenBSD
Posts: 982
Blog Entries: 2

Rep: Reputation: 244Reputation: 244Reputation: 244
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 03:34 AM.
 
Old 07-29-2014, 05:10 AM   #3
FaisalSeif
LQ Newbie
 
Registered: Jun 2014
Posts: 2

Original Poster
Rep: Reputation: Disabled
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
 
Old 07-30-2014, 02:58 PM   #4
rm%rf
LQ Newbie
 
Registered: Oct 2009
Distribution: Slackware 13
Posts: 17

Rep: Reputation: 0
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
 
Old 07-30-2014, 03:11 PM   #5
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,573

Rep: Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142Reputation: 2142
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?
 
Old 07-31-2014, 02:02 PM   #6
brianL
LQ 5k Club
 
Registered: Jan 2006
Location: Oldham, Lancs, England
Distribution: Slackware64 15; SlackwareARM-current (aarch64); Debian 12
Posts: 8,298
Blog Entries: 61

Rep: Reputation: Disabled
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 02:10 PM. Reason: missed an h out, dozy bugger!
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
explanation of a code uma.g Linux - Newbie 2 02-03-2013 10:23 AM
GIT - explanation casperdaghost Linux - Newbie 4 07-04-2012 04:44 PM
ls */ explanation zeusys Linux - Newbie 3 08-17-2011 11:41 PM
[SOLVED] explanation NetStat -e pkhutch2455 Linux - Newbie 1 05-31-2011 10:11 PM
I Could Use An Explanation winger Linux - General 3 04-13-2002 10:32 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 02:15 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration