LinuxQuestions.org
Visit Jeremy's Blog.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - General
User Name
Password
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


Reply
  Search this Thread
Old 01-26-2006, 01:24 PM   #1
hkl8324
Member
 
Registered: Aug 2003
Location: Hong Kong, China
Distribution: Ubuntu 10.04
Posts: 234

Rep: Reputation: 30
A stupid question about copying files


What do i need to type when i want to copy all the *.ogg file on /mnt/ntfs1 (My windows drive, many ogg files scatter all over the drive) to my Linux home directory?
 
Old 01-26-2006, 01:50 PM   #2
rjwilmsi
Member
 
Registered: Mar 2005
Location: UK
Distribution: opensuse 12.2 x86_64
Posts: 563

Rep: Reputation: 38
cp -r /mnt/ntfs1/*.ogg

This will copy all OGG files from your Windows drive (searching recursively) to the drive you're in when you execute the command.
 
Old 01-26-2006, 02:01 PM   #3
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by rjwilmsi
cp -r /mnt/ntfs1/*.ogg

This will copy all OGG files from your Windows drive (searching recursively) to the drive you're in when you execute the command.
Actually, that would copy any .ogg files in the root of the ntfs partition. It would also copy any directories ending in .ogg (an unlikely occurance).

I think a solution more targeted at what the user seeks would be:
Code:
find /mnt/ntfs -iname '*.ogg' -exec cp {} /NEW/LOCATION/FOR/OGGS \;
 
Old 01-26-2006, 02:09 PM   #4
hkl8324
Member
 
Registered: Aug 2003
Location: Hong Kong, China
Distribution: Ubuntu 10.04
Posts: 234

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by Matir
Actually, that would copy any .ogg files in the root of the ntfs partition. It would also copy any directories ending in .ogg (an unlikely occurance).

I think a solution more targeted at what the user seeks would be:
Code:
find /mnt/ntfs -iname '*.ogg' -exec cp {} /NEW/LOCATION/FOR/OGGS \;
Thank you, but can you explain to me what does those command exactly mean? (I want to learn more)

Last edited by hkl8324; 01-26-2006 at 02:12 PM.
 
Old 01-26-2006, 02:27 PM   #5
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
Quote:
Originally Posted by hkl8324
Thank you, but can you explain to me what does those command exactly mean? (I want to learn more)
Code:
find /mnt/ntfs -iname '*.ogg' -exec cp {} /NEW/LOCATION/FOR/OGGS \;
Find takes a path and zero or more 'operators'. The first argument to find is the path, which indicates where find is to start its search. It is then followed by operators which specify what files to find. In this case, I told it a case insensitive search on name, to match the express '*.ogg', which is (as you might imagine) all files ending in .ogg. Finally, you have (optional) operators which specify what to do with found files. -exec asks for that command to be run on each of them. The default operator is simply '-print', which prints a list of found files, one per line. See the man page for find for more details.
 
Old 01-26-2006, 03:34 PM   #6
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
That command is still copying directories named "*.ogg", if any.
This can be avoided that way:
Code:
find /mnt/ntfs -type f -iname "*.ogg" -exec cp {} /NEW/LOCATION/FOR/OGGS \;
 
Old 01-26-2006, 03:45 PM   #7
Matir
LQ Guru
 
Registered: Nov 2004
Location: San Jose, CA
Distribution: Debian, Arch
Posts: 8,507

Rep: Reputation: 128Reputation: 128
An excellent point, though I doubt directories ending in .ogg are terribly common.
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
find and delete files - stupid question though smshuja Linux - Newbie 5 12-29-2005 01:21 AM
Stupid, stupid question; I lost Klaptop. :( Surfrider Slackware 2 08-31-2005 09:12 PM
A really dumb question about copying files... byz78 Linux - Newbie 4 08-25-2005 07:55 PM
Just one more Stupid Question Uninstall Files?? ddrfreak Mandriva 5 12-12-2004 11:05 AM
question on copying files alexchannell Linux - Software 6 08-07-2004 04:14 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - General

All times are GMT -5. The time now is 06:52 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration