Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question?
If it is not in the man pages or the how-to's 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. |
|
 |
05-03-2008, 09:15 PM
|
#1
|
|
Member
Registered: Jul 2005
Distribution: Mandrake 6.1
Posts: 59
Rep:
|
How to find files and copy the found files to the floppy in one command
I am trying to find all files which are called index.* and at the same time want to copy the found files to the floppy drive ?
To find I typed in find / -name index* but how can I copy the same files to the floppy drive ?
Thanks
|
|
|
|
05-03-2008, 09:54 PM
|
#2
|
|
Member
Registered: Jan 2007
Location: Pennsylvania
Distribution: Ubuntu 8.10 Server/9.04 Desktop, openSUSE 11.1
Posts: 154
Rep:
|
Quote:
Originally Posted by justmehere
I am trying to find all files which are called index.* and at the same time want to copy the found files to the floppy drive ?
To find I typed in find / -name index* but how can I copy the same files to the floppy drive ?
Thanks
|
Hello,
why not try some variation of the following command. I don't use find, but rather locate.
Code:
root@mybox:/# for i in `locate index.`; do cp $i /media/destination/; done;
Please test and research before deploying, but this should be a good starting point. If you find that files are missing, run 'updatedb' as root to repopulate the locate database.
- Jim
|
|
|
|
05-03-2008, 10:20 PM
|
#3
|
|
Moderator
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733
|
You need to put the name inside double quotes:
Using / as the base directory isn't a good idea because you will be searching the entire system. You should have a better idea where the file would be.
find /usr -name "index*" -exec cp '{}' /mnt/floppy/ \;
Last edited by jschiwal; 05-06-2008 at 12:08 AM.
Reason: fixed ending
|
|
|
|
05-03-2008, 10:23 PM
|
#4
|
|
Member
Registered: Apr 2008
Posts: 310
Rep:
|
Hey There,
You can also use the -exec flag for your find command, so it would look like this:
find / -name ".index*" -exec cp {} /dev/fd/ \;
Assuming /dev/fd is your floppy. As per the other suggestion, please test beforehand, just in case. That's always good advice
Best wishes,
Mike
|
|
|
|
05-04-2008, 11:11 AM
|
#5
|
|
Member
Registered: Jul 2005
Distribution: Mandrake 6.1
Posts: 59
Original Poster
Rep:
|
Thanks to all replies. I'll try them out.
|
|
|
|
05-04-2008, 01:44 PM
|
#6
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,902
|
The problem with that approach "cp {} /mnt/fd" is that if two
files happen to have the same name you'll only keep the version
it found on HDD last on floppy.
To eggixyz:
You *don't* copy to the raw device.... try the mounted device.
Cheers,
Tink
|
|
|
|
05-04-2008, 02:15 PM
|
#7
|
|
Member
Registered: Nov 2007
Location: Pakistan
Distribution: Redhat and Debian
Posts: 302
Rep:
|
to execute any command while using find use ' \; '
|
|
|
|
05-04-2008, 06:11 PM
|
#8
|
|
Member
Registered: Jul 2005
Distribution: Mandrake 6.1
Posts: 59
Original Poster
Rep:
|
Quote:
Originally Posted by jschiwal
You need to put the name inside double quotes:
Using / as the base directory isn't a good idea because you will be searching the entire system. You should have a better idea where the file would be.
find /usr -name "index*" -exec cp '{}' /mnt/floppy/
|
Many thanks for the above example but I am getting the error when running the above exact command:
find: missing argument to '-exec'
|
|
|
|
05-04-2008, 06:28 PM
|
#9
|
|
Member
Registered: Jul 2005
Distribution: Mandrake 6.1
Posts: 59
Original Poster
Rep:
|
Quote:
Originally Posted by eggixyz
Hey There,
You can also use the -exec flag for your find command, so it would look like this:
find / -name ".index*" -exec cp {} /dev/fd/ \;
Assuming /dev/fd is your floppy. As per the other suggestion, please test beforehand, just in case. That's always good advice
Best wishes,
Mike
|
Thanks for the above reply. This one worked for me. I might have been doing something wrong on the other suggesions.
|
|
|
|
05-04-2008, 06:35 PM
|
#10
|
|
Moderator
Registered: Apr 2002
Location: in a fallen world
Distribution: slackware by choice, others too :} ... android.
Posts: 22,902
|
Quote:
Originally Posted by justmehere
Thanks for the above reply. This one worked for me. I might have been doing something wrong on the other suggesions.
|
The copy may have worked - but is the data on the floppy?
Cheers,
Tink
|
|
|
|
05-04-2008, 07:36 PM
|
#11
|
|
Member
Registered: Jul 2005
Distribution: Mandrake 6.1
Posts: 59
Original Poster
Rep:
|
Quote:
Originally Posted by Tinkster
The copy may have worked - but is the data on the floppy?
Cheers,
Tink
|
Yes the files were copied to the floppy and they are valid files. Not sure may have missed the odd index file. But overall its working.
|
|
|
|
05-04-2008, 11:29 PM
|
#12
|
|
Member
Registered: Apr 2008
Posts: 310
Rep:
|
Hey There,
Glad that's working out for you
To clarify, Tinkster is correct that you should mount the floppy and then write to that file. I just shot that out there quickly.
The reason for this is that, if /dev/fd doesn't have a floppy mounted, your command won't fail. It's better practice to mount the floppy on /dev/fd and then do you cp to that mountpoint.
Thanks for heads-up, Tinkster. I often type first and ask questions later
Best wishes,
Mike
|
|
|
|
| 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 12:53 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
|
|