Reputation: 141
How can i only copy files which are owned by some user. is there a way to specify user name in copy command? i have few files in my home direct which are owned by some other user, i want to copy only those files to some other directory.How to filter it.
Upvotes: 2
Views: 4230
Reputation: 410
You can find the files owned by user with find
command and then use cp
to copy your files.
Example:
find all .txt files from user:
find /path/to/directory -user <username> -name "*.txt"
You can pipe it with the cp
command to copy.
Or a one liner with find
:
find /var/www -user vivek -name "*.pl" -exec cp -f source dest
Upvotes: 2