LinuxQuestions.org
Visit the LQ Articles and Editorials section
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
 
LinkBack Search this Thread
Old 12-14-2007, 11:11 AM   #1
Rotwang
Member
 
Registered: Jan 2004
Distribution: CentOS
Posts: 280

Rep: Reputation: 30
Copy files in subdirs to one dir


If I have a directory tree, how do I copy all the files within it into one directory? I don't want to copy the dirs, only the files. I essentially want to collapse the directory structure.

thanks
 
Old 12-14-2007, 12:00 PM   #2
unSpawn
Moderator
 
Registered: May 2001
Posts: 21,593
Blog Entries: 47

Rep: Reputation: 1409Reputation: 1409Reputation: 1409Reputation: 1409Reputation: 1409Reputation: 1409Reputation: 1409Reputation: 1409Reputation: 1409Reputation: 1409
'find /some/dir -type f | xargs -iF cp 'F' /some/otherdir'?
 
Old 12-14-2007, 12:01 PM   #3
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 51
This should work:
Code:
find /some/dir/structure -type f -exec cp "{}" /flatdir \;
 
Old 12-14-2007, 12:04 PM   #4
nx5000
Senior Member
 
Registered: Sep 2005
Location: Out
Posts: 3,307

Rep: Reputation: 51
Quote:
Originally Posted by unSpawn View Post
'find /some/dir -type f | xargs -iF cp 'F' /some/otherdir'?
obfuscation is not permitted
 
Old 12-14-2007, 01:30 PM   #5
Rotwang
Member
 
Registered: Jan 2004
Distribution: CentOS
Posts: 280

Original Poster
Rep: Reputation: 30
Quote:
Originally Posted by nx5000 View Post
This should work:
Code:
find /some/dir/structure -type f -exec cp "{}" /flatdir \;
worked perfect thanks!
 
  


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Command to display /dir, /dir/sub, /dir/sub/files knockout_artist Linux - Newbie 9 10-25-2007 02:57 PM
How can I copy an entire CD (from WinXP) to a dir on my Linux server? hmendoza Linux - General 2 04-04-2007 06:06 PM
Q. moving /bin dir files to /dev dir?? Texas_student Linux - Software 2 03-26-2006 11:42 PM
how copy from floppy to dir? cauge Mandriva 6 12-09-2003 11:12 AM
copy 1 file to multiple dir script carpman Linux - General 14 02-07-2002 09:29 AM


All times are GMT -5. The time now is 11:06 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
Open Source Consulting | Domain Registration