Linux - General This Linux forum is for general Linux questions and discussion.
If it is Linux Related and doesn't seem to fit in any other forum then this is the place. |
| Notices |
Welcome to LinuxQuestions.org, a friendly and active Linux Community.
You are currently viewing LQ as a guest. By joining our community you will have the ability to post topics, receive our newsletter, use the advanced search, subscribe to threads and access many other special features. Registration is quick, simple and absolutely free. Join our community today!
Note that registered members see fewer ads, and ContentLink is completely disabled once you log in.
Are you new to LinuxQuestions.org? Visit the following links:
Site Howto |
Site FAQ |
Sitemap |
Register Now
If you have any problems with the registration process or your account login, please contact us. If you need to reset your password, click here.
Having a problem logging in? Please visit this page to clear all LQ-related cookies.
 |
GNU/Linux Basic Guide
This 255-page guide will provide you with the keys to understand the philosophy of free software, teach you how to use and handle it, and give you the tools required to move easily in the world of GNU/Linux. Many users and administrators will be taking their first steps with this GNU/Linux Basic guide and it will show you how to approach and solve the problems you encounter.
Click Here to receive this Complete Guide absolutely free. |
|
 |
09-11-2005, 12:11 PM
|
#1
|
|
Member
Registered: Jan 2002
Location: Shelby, NC, US
Distribution: Slackware 12.2
Posts: 127
Rep:
|
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!
|
|
|
|
09-11-2005, 12:24 PM
|
#2
|
|
Moderator
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,505
Rep: 
|
Well, if you literally mean every file ending in .conf:
Code:
find / -iname '*.conf' -print0 | xargs -0 -i cp {} /backupdirectory
Just change /backupdirectory to taste.
Edit:
Or more simply, and I somehow didn't think of this:
Code:
find / -iname '*.conf' -exec cp {} /backupdirectory \;
|
|
|
|
09-11-2005, 01:47 PM
|
#3
|
|
Member
Registered: Jan 2002
Location: Shelby, NC, US
Distribution: Slackware 12.2
Posts: 127
Original Poster
Rep:
|
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
Any ideas as to what's causing that? Seems like the command is being executed twice.
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.
|
|
|
|
09-11-2005, 02:32 PM
|
#4
|
|
Moderator
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,505
Rep: 
|
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 \;
|
|
|
|
09-11-2005, 08:46 PM
|
#5
|
|
Member
Registered: Jan 2002
Location: Shelby, NC, US
Distribution: Slackware 12.2
Posts: 127
Original Poster
Rep:
|
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.
Last edited by Earl Parker II; 09-11-2005 at 08:57 PM.
|
|
|
|
09-11-2005, 09:20 PM
|
#6
|
|
Moderator
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,505
Rep: 
|
Odd. But it actually works otherwise?
|
|
|
|
09-12-2005, 12:12 AM
|
#7
|
|
Member
Registered: Jan 2002
Location: Shelby, NC, US
Distribution: Slackware 12.2
Posts: 127
Original Poster
Rep:
|
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.
|
|
|
|
09-12-2005, 07:28 AM
|
#8
|
|
Moderator
Registered: Nov 2004
Location: San Jose, CA
Distribution: Ubuntu
Posts: 8,505
Rep: 
|
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.
|
|
|
|
09-12-2005, 08:54 AM
|
#9
|
|
Member
Registered: Jan 2002
Location: Shelby, NC, US
Distribution: Slackware 12.2
Posts: 127
Original Poster
Rep:
|
I'll play with it when I get a little time and will let you know if I come up with anything.
|
|
|
|
| Thread Tools |
Search this Thread |
|
|
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -5. The time now is 11:29 PM.
|
|
LinuxQuestions.org is looking for people interested in writing
Editorials, Articles, Reviews, and more. If you'd like to contribute
content, let us know.
|
Latest Threads
LQ News
|
|