Thursday, November 15, 2012

How to find any specific file(s) and then copy those in a directory?

It was tested recently on Redhat Linux 6. The requirement is to find the files owned by some user and copy all those files into a single pre-selected directory. There are at least two ways (I am sure there are even more ways to do this - but here is what I used)

Method 1:
# find / -user testuser -type f -exec cp {} /root/BACKUP \;

Method 2:
# find / -user testuser -type f | cpio -pvdmu /root/BACKUP 

No comments: