LinuxQuestions.org
Welcome to the most active Linux Forum on the web.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
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


Reply
  Search this Thread
Old 03-29-2010, 02:39 AM   #1
archnemesis
Member
 
Registered: Dec 2009
Posts: 31

Rep: Reputation: 0
copy range of files in directory?


I want to know how to copy a range of files from one directory to another . For example say I list the contents of a directory, how would i copy files 5-15 to another directory?
 
Old 03-29-2010, 02:47 AM   #2
Sayan Acharjee
Member
 
Registered: Feb 2010
Location: Chennai, India
Distribution: Manjaro
Posts: 616

Rep: Reputation: 64
Quote:
Originally Posted by archnemesis View Post
I want to know how to copy a range of files from one directory to another . For example say I list the contents of a directory, how would i copy files 5-15 to another directory?
You can use wildcards to copy some specific files, like you can use the follwing command to copy all the files that start with the letter 's':

Quote:
cp s* destination
To copy all the doc files you can use:

Quote:
cp *.doc destination
 
Old 03-29-2010, 03:15 AM   #3
PMP
Member
 
Registered: Apr 2009
Location: ~
Distribution: RHEL, Fedora
Posts: 381

Rep: Reputation: 58
Code:
ls -1 | sed -n '5,15p' | xargs -i cp {} <destination_directory>
 
Old 03-29-2010, 05:59 AM   #4
archnemesis
Member
 
Registered: Dec 2009
Posts: 31

Original Poster
Rep: Reputation: 0
thanks guys!
 
  


Reply


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
find files with pattern, then copy those files to another directory ncsuapex Programming 4 08-13-2010 04:38 PM
how to copy files from directory spartanz Linux - Newbie 3 12-22-2009 02:29 AM
How to Copy files from local directory to a particular directory using alias dynamics Linux - Newbie 7 09-11-2009 05:19 PM
How to copy files after search in array from this directory to another directory! phanvinhgiap Programming 4 01-04-2009 07:48 PM
copy files from directory to directory without subfile ALInux Linux - General 2 06-03-2005 12:51 PM


All times are GMT -5. The time now is 01:44 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration