LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices

Reply
 
Search this Thread
Old 05-11-2008, 10:41 AM   #1
biswa_nayak
LQ Newbie
 
Registered: May 2008
Posts: 1

Rep: Reputation: 0
How to copy a specific no of files from a group of files


Hi ALL,


I have a task to completed . There are around 20,000 files in the folder and i have to copy 1500 files from the current directory to a specific directory . How can i do it ??? Please guide me . it is very urgent


More to add , only 1500 files , not a single more than that or less than that

Last edited by biswa_nayak; 05-11-2008 at 10:43 AM.
 
Old 05-11-2008, 11:02 AM   #2
cmnorton
Member
 
Registered: Feb 2005
Distribution: Ubuntu, CentOS
Posts: 585

Rep: Reputation: 35
More information needed

Do you want any 1,500 files?

Do you want 1,500 files using a filter, like a files beginning with 'b' or all executable files?

Suggest you start with the find command and develop a loop from that.
 
Old 05-11-2008, 12:21 PM   #3
matthewg42
Senior Member
 
Registered: Oct 2003
Location: UK
Distribution: Kubuntu 12.10 (using awesome wm though)
Posts: 3,530

Rep: Reputation: 63
You could use ls to list the files, and take the first or last 1500 of them using head or tail as you wish, e.g.
Code:
ls |head -1500 |while read f; do echo cp "$f" "/your/destination/directory/"
THat command will just echo the copy commands it will execute - check that they are sane and what you want to do, and then do the command again, but take out the echo.
 
  


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
Delete/move/copy files of specific date imsajjadali Red Hat 26 11-07-2013 11:34 PM
Command to copy files/folders but skip bad/corrupt files?? leemoreau Linux - Newbie 2 04-02-2007 02:27 PM
BASH script to copy specific files ScottReed Linux - Software 5 07-20-2006 11:08 AM
copy specific files with directory stucture rincewind Linux - Software 1 06-22-2006 07:58 AM
How to do recursive file copy of directory for specific files? Arodef Linux - Newbie 4 06-29-2004 05:35 PM


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

Main Menu
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
identi.ca: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration