need help with copying files
This probably pretty simple but I haven't quite figured out how to do it. I want to copy every .conf file on my HD to a single folder for backup purposes. Backing up isn't a problem but I haven't figured out the correct syntax to do the copy deal. Does anyone have any suggestions? Thanks for any help!
|
Well, if you literally mean every file ending in .conf:
Code:
find / -iname '*.conf' -print0 | xargs -0 -i cp {} /backupdirectory Edit: Or more simply, and I somehow didn't think of this: Code:
find / -iname '*.conf' -exec cp {} /backupdirectory \; |
Thank you! The second command works perfectly (didn't try the first one yet). Now, just one more question- when I run the command, for every file that's copied I'm getting:
Code:
cp: '/conf/<filename>' and '/conf/<filename>' are the same file Later, when I have some time, I'm getting into the man pages to analyze the commands you've given me to see how they work. |
Is /conf the directory you are using for backups? If so, it may be refinding the files. Oops. Try:
Code:
find / -iname '*.conf' \! -name "/conf/*" -exec cp {} /conf \; |
Yes it is. I'll give your fix a try in the morning and let you know- thanks again for the help!
Update: Tried it tonight, same error messages. |
Odd. But it actually works otherwise?
|
Seems to work perfectly. Truthfully the error message deal is of academic interest only as you've solved the original problem. Would be interesting to figure out, though. I changed a couple of things around just to see the effect but haven't hit on anything yet.
|
Well, it seems to be caused by the search find the copy of the file in the backup directory and trying to recopy it. I would've thought my other statement would exclude those files, but maybe not.
|
I'll play with it when I get a little time and will let you know if I come up with anything.
|
All times are GMT -5. The time now is 07:02 AM. |