Go Back   The UNIX and Linux Forums > Top Forums > UNIX for Dummies Questions & Answers
.
google site



UNIX for Dummies Questions & Answers If you're not sure where to post a UNIX or Linux question, post it here. All UNIX and Linux newbies welcome !!

Closed Thread
English Japanese Spanish French German Portuguese Italian Powered by Powered by Google
 
Thread Tools Search this Thread Rate Thread Display Modes
  #1 (permalink)  
Old 02-23-2006
Registered User
 

Join Date: Oct 2003
Location: Brazil
Posts: 42
cp without maintaining the soucre directory tree hierarchy

Hi guys.

I'm willing to copy a specific file system hierarchy, but I would not like to maintain the directory tree organization.


For example:

Let's say /a/b/c is the fs I'm wanting to copy to my destination,
and that c is a directory with 30 files, 10 on /a/b/c , 10 on a/b/c/c1 and 10 on a/b/c/c2 , I'd like to have all files from inside /a/b/c into my destination, but all of them scattered within a/b/c/ only , not obeying to the source directory tree (I wouldn't, hence, have the directories c1 nor c2, but I would have 30 files)

more clearly, how do I copy a multi-directory structure and have all the resulting files in a single directory destination, with all the files ending in one directory, alone ?


Thanks in advance,
Abrahao.
Sponsored Links
  #2 (permalink)  
Old 02-23-2006
Registered User
 

Join Date: Feb 2006
Location: Schenectady, NY
Posts: 134
I believe this is what you're looking for

find /a/b/c -depth -type f -print -exec cp {} /a/b/c/ \;

If you want to empty the sub-directories, use "mv" instead of "cp"

I would recommend copying the files to a directory NOT in the search path. Worst case scenerio, the copy/move will fail because the source and target names are identical.
  #3 (permalink)  
Old 03-03-2006
Registered User
 

Join Date: Oct 2003
Location: Brazil
Posts: 42
it seems issuing only
find <file system from where I want the copy to begin> -name <pattern> -exec cp {} <destination_dir> \; worked fine for this purpose.

Thank you all, anyway!
Sponsored Links
Closed Thread

Bookmarks

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes Rate This Thread
Rate This Thread:

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


More UNIX and Linux Forum Topics You Might Find Helpful
Thread Thread Starter Forum Replies Last Post
Protecting the directory tree rooneyl UNIX for Dummies Questions & Answers 2 02-17-2008 05:59 PM
directory tree ravi raj kumar Shell Programming and Scripting 3 01-24-2008 01:08 PM
Need to search and replace in multiple files in directory hierarchy umen Shell Programming and Scripting 3 12-24-2007 04:56 AM
directory as tree anything2 Programming 2 03-01-2007 09:38 AM
Space Used by Directory Tree johnk99 Filesystems, Disks and Memory 1 07-22-2002 01:30 PM



All times are GMT -4. The time now is 09:43 AM.


Powered by: vBulletin, Copyright ©2000 - 2006, Jelsoft Enterprises Limited. Language Translations Powered by .
vBCredits v1.4 Copyright ©2007 - 2008, PixelFX Studios
The UNIX and Linux Forums Content Copyright ©1993-2010. All Rights Reserved.Ad Management by RedTyger

Content Relevant URLs by vBSEO 3.2.0