Latest LQ Deal: Complete CCNA, CCNP & Red Hat Certification Training Bundle
Go Back > Forums > Linux Forums > Linux - Newbie
User Name
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!


  Search this Thread
Old 08-18-2011, 03:02 AM   #1
LQ Newbie
Registered: Aug 2011
Posts: 9

Rep: Reputation: Disabled
Help in copying multiple files

I need some help in copying multiple files from different directory trees to a separate directory tree with same names.
eg. I have a bunch of directories with various sub directories.In each of the sub directory i need to find *.txt files and copy those files into a different directory having same directory tree as my previous directory.
Old 08-18-2011, 04:02 AM   #2
David the H.
Bash Guru
Registered: Jun 2004
Location: Osaka, Japan
Distribution: Debian + kde 4 / 5
Posts: 6,834

Rep: Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976Reputation: 1976
Uum, ok. You didn't really specify where you need help, but we'll go with it.

So how do we determine which files to copy? What is the directory structure they are in? Where do you want to move them? Are there any "gotchas" to worry about, such as files to avoid?

Most important, what have you tried so far? You have searched the web and LQ, and tried out some things first, right?

Anyway, here's a hint to get you started:
Old 08-18-2011, 04:18 AM   #3
Registered: Aug 2011
Posts: 47

Rep: Reputation: Disabled
Here's a little command that will print the name + the path of all the .txt files in the current dir :

for i in `find .`
echo $i

spring logout

Last edited by allwimb; 12-12-2011 at 06:44 AM.
Old 08-18-2011, 04:38 AM   #4
Registered: Aug 2011
Posts: 64

Rep: Reputation: Disabled
for i in `find /yourdirectory -name *.txt`
cp $i destinationPath

generics array

Last edited by salemeni; 12-06-2011 at 04:00 AM.


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
copying multiple files in multiple folders ?? stratotak Linux - Newbie 2 02-21-2009 10:41 AM
Copying Multiple Files babu198649 Linux - Newbie 2 01-23-2009 08:43 AM
Kaudiocreator seems to hang copying multiple files tur third Linux - Software 6 03-28-2006 04:49 PM
Copying files from multiple folders into one aardwolf64 Linux - General 4 01-03-2006 12:53 AM
copying multiple files..??? krazykow Linux - Enterprise 6 09-09-2004 02:05 AM > Forums > Linux Forums > Linux - Newbie

All times are GMT -5. The time now is 02:53 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration