Visit the LQ Articles and Editorials section
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 03-18-2008, 10:13 PM   #1
Registered: Jan 2008
Location: Indonesia, tanah air beta
Distribution: Knoppix v5
Posts: 97

Rep: Reputation: 15
Copy a hundred...

What is the command for copying lot of files? Said in one folder, i want to copy 10 files among 100 files. What is the command? It not efficient if i used cp files.ext one by one isn'it?. Helppp meee pleaseee
Old 03-18-2008, 10:18 PM   #2
LQ Addict
Registered: Jul 2002
Location: East Centra Illinois, USA
Distribution: Debian Squeeze
Posts: 5,840

Rep: Reputation: 342Reputation: 342Reputation: 342Reputation: 342
How do you distinguish which 10 files of the 100 are to be copied? If that isn't a common feature to focus on, then you have no choice but to cp one by one.
Old 03-18-2008, 10:20 PM   #3
LQ Guru
Registered: Feb 2004
Location: SE Tennessee, USA
Distribution: Gentoo, LFS
Posts: 5,893

Rep: Reputation: 1357Reputation: 1357Reputation: 1357Reputation: 1357Reputation: 1357Reputation: 1357Reputation: 1357Reputation: 1357Reputation: 1357Reputation: 1357
There's a lot of stuff. How about reading help bash?
Old 03-18-2008, 10:57 PM   #4
LQ Newbie
Registered: Feb 2007
Location: New Zealand
Distribution: Kubuntu
Posts: 11

Rep: Reputation: 0
There are so many ways to do it. As bigrigdriver suggested, it depends on how you distinguish the files you want to copy from the ones you don't.

If it's only 10 files out of 100, you might be better off using a file manager with a GUI such as Nautilus on Gnome or Konqueror/Dolphin on KDE.

If you want to use the command line, then suppose, for example, that you want to copy all of the files that were modified more than one day ago ...

find -mtime +1 -exec -print cp {} \;
I'd break down that command for you, but then you wouldn't have any reason to type man find

Old 03-18-2008, 11:01 PM   #5
LQ Guru
Registered: Aug 2001
Location: Fargo, ND
Distribution: SuSE AMD64
Posts: 15,733

Rep: Reputation: 657Reputation: 657Reputation: 657Reputation: 657Reputation: 657Reputation: 657
How are the 10 files out of 100 distinguished from the others?

Sometimes you can use wildcards to select the files you want.
example: cp *.jpg pictures/
example: cp spooky{0..9}.txt chapters/

If you want to copy all files in the current directory that are less than 30 minutes old:
example: find ./ -cmin -30 -exec cp '{}' newfiles/ \;

If they are arbitrary files, include them in the argument. The last argument is the destination and needs to be a directory:
copy file1 file2 file3 file4 file5 destdir/



Thread Tools Search this Thread
Search this Thread:

Advanced Search

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 Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
LXer: Nine Hundred Swedish Pharmacies Switch to Linux LXer Syndicated Linux News 0 09-19-2007 06:10 PM
LXer: Reaches Two Million Posts and Two Hundred Thousand Members LXer Syndicated Linux News 0 12-21-2005 06:31 AM
automatised changing of tone curve / light in several hundred pictures ungua Linux - Software 3 02-01-2005 01:56 PM
I know you have heard this a hundred times but... blmartin777 Debian 9 04-25-2004 10:05 PM
boot error after using Copy Commander to copy debian system onto larger new drive Interceptor Linux - Hardware 7 05-04-2003 12:40 PM

All times are GMT -5. The time now is 05:34 PM.

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