LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   copy range of files in directory? (https://www.linuxquestions.org/questions/linux-newbie-8/copy-range-of-files-in-directory-798563/)

archnemesis 03-29-2010 01:39 AM

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?

Sayan Acharjee 03-29-2010 01:47 AM

Quote:

Originally Posted by archnemesis (Post 3916266)
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

PMP 03-29-2010 02:15 AM

Code:

ls -1 | sed -n '5,15p' | xargs -i cp {} <destination_directory>

archnemesis 03-29-2010 04:59 AM

thanks guys!


All times are GMT -5. The time now is 03:59 AM.