The purpose of this command is to copy all files that belong to the user ‘bob’ into the ./bobfiles/ folder in the current working directory. I was able to research this and find this example and make this work, but I’m not sure about the logic of this command.
I get that it finds all files in ‘.’ that belong to the user ‘bob’ and then executes the ‘cp’ function to copy them to ./bobfiles/. But I’m not sure what the two sets of {} do or the ; does.
“Obviously” -exec … must be terminated with either a semicolon ( ; ) or a plus sign (+). Semicolon is a special character in the shell (or, at least, every shell I’ve ever used), so, if it is to be used as part of the find command, it must be escaped or quoted (\;, “;”, or ‘;’).
The curly braces will be replaced by the results of the find command: find . -user bob -exec cp {} ./bobfiles/{} ;
Equal: find . -user bob -exec cp {file1,file2.,,,etc} ./bobfiles/{file1,file2.,,,etc} ;
Where file1,file2.,,,etc are the files owoned by bob user and comes from the result of find . -user bob
Execute command ; true if 0 status is returned. All following arguments to find are taken to be arguments to the command until an argument consisting of ‘ ; ’ is encountered. The string ‘ {} ’ is replaced by the current file name being processed everywhere it occurs in the arguments to the command, not just in arguments where it is alone, as in some versions of find .