How to find files?
How to find all the files of a particular user and copy and paste them in a directory?
|
Code:
cp -R /home/username <new path> Some more detail on what you are doing will probably get a better answer. |
Quote:
|
You can use the find command for things like this. Its "-user" test is what you want to be looking at.
|
Code:
# find / -user sunveer -exec cp -iv /desired/dir {} \;
|
Quote:
|
Did you typed in your username correctly? I mean username in your GNU/Linux system.
It should be as in Code:
echo $USER |
Quote:
|
Isn't the cp line missing a -t option to designate /desired/dir as the destination directory? Otherwise, shouldn't the file to be copied ({}) appear first than the destination directory?
|
414N, you're right. Looked it up and found corrections. OP, see URL.
|
Will this cmd serve the purpose?
#find / -user UNAME | cpio -pdumv /path/ |
Wrap your code up with forum tags.
I don't know about cpio, didn't work with it. What's wrong with suggested command? Code:
# find /where/to/search -user sunveer -exec cp -ipv {} /where/to/copy \; |
Quote:
Thanks. |
All times are GMT -5. The time now is 03:52 AM. |