The Linux Administration group is for the discussion of technical issues technical issues that arise during the administration of Linux systems, including maintaining the operating system and supporting end-user applications.

What is This Command Doing?

I feel like I completely missing something. I have found this: find / -user harry -exec cp -rfp {} /mkdir/file \;. I don’t really understand the exec option and the curly braces {}. What is going on with this command? I am a bit of a newb so I’m trying to understand what is going on and how I can use this.

The command says: Find, starting at the root directory, all
files owned by user (login) harry, then execute (exec) a
recursive copy of the file(s) found to /mkdir/file, and
preserve the file attributes (ownership, permissions) in doing
so. The curly braces are a stand-in for the file(s)
respectively found in the search (that is, substitute the found
filename here: {}). A recursive copy is meaningless unless the
"file" is in fact a directory.

find : command to search , / = place of search in this example is root (that mean all)
exec = run another job after doing search and at this example
cp = copy command
rfp = r recusive in another work copy all file directory and directory under file
f = force