LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Help in copying multiple files (https://www.linuxquestions.org/questions/linux-newbie-8/help-in-copying-multiple-files-897996/)

meet10may 08-18-2011 02:02 AM

Help in copying multiple files
 
Hi,
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.
Thanks

David the H. 08-18-2011 03:02 AM

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:

http://mywiki.wooledge.org/UsingFind

allwimb 08-18-2011 03:18 AM

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 .`
do
echo $i
done

spring logout

salemeni 08-18-2011 03:38 AM

for i in `find /yourdirectory -name *.txt`
do
cp $i destinationPath
done

generics array


All times are GMT -5. The time now is 09:28 PM.