LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   how to select and copy multiple directories (https://www.linuxquestions.org/questions/linux-newbie-8/how-to-select-and-copy-multiple-directories-900593/)

zeusys 09-01-2011 02:49 PM

how to select and copy multiple directories
 
Hi
I want to copy multiple directories with one cp command.

Code:

-rw-r--r--. 1 1000 1000 37040 Jul 10 20:01 cherrytree.pot
drwxr-xr-x. 3 1000 1000  4096 Jul 10 20:37 cs
-rw-r--r--. 1 1000 1000 51954 Jul 10 20:06 cs.po
drwxr-xr-x. 3 1000 1000  4096 Jul 10 20:37 de
-rw-r--r--. 1 1000 1000 51185 Jul 10 20:05 de.po
drwxr-xr-x. 3 1000 1000  4096 Jul 10 20:37 es
-rw-r--r--. 1 1000 1000 52367 Jul 10 20:07 es.po
drwxr-xr-x. 3 1000 1000  4096 Jul 10 20:37 fr
-rw-r--r--. 1 1000 1000 53069 Jul 10 20:08 fr.po
-rwxr-xr-x. 1 1000 1000  178 Jun 29 01:15 i18n_create_lang_file.sh
-rwxr-xr-x. 1 1000 1000  731 Jun 29 01:27 i18n_po_to_mo.py
-rwxr-xr-x. 1 1000 1000  477 Jun 29 01:27 i18n_pot_to_updated_po.py
-rwxr-xr-x. 1 1000 1000  338 Jun 29 01:15 i18n_update_pot.sh
drwxr-xr-x. 3 1000 1000  4096 Jul 10 20:37 it
-rw-r--r--. 1 1000 1000 51754 Jul 10 20:02 it.po
drwxr-xr-x. 3 1000 1000  4096 Jul 10 20:37 pl
-rw-r--r--. 1 1000 1000 50930 Jul 10 20:10 pl.po
drwxr-xr-x. 3 1000 1000  4096 Jul 10 20:37 ru
-rw-r--r--. 1 1000 1000 60808 Jul 10 20:07 ru.po
drwxr-xr-x. 3 1000 1000  4096 Jul 10 20:37 uk
-rw-r--r--. 1 1000 1000 59566 Jul 10 20:08 uk.po

As you see,there are both files and directories.I need to copy only directories and I want to copy these directories simultaneously(with one cp command).
I know it would be done by using xargs,but I don't know how to use it.

Is there any way to achieve this goal?
please guide me.
thank you

T3RM1NVT0R 09-01-2011 03:03 PM

@ Reply
 
Hi there,

You can do that using following command:

cp -arv directory1 directory2 directory3 /destination-directory

Make sure that you run this command from the location where the source directories are located.

I hope this helps.

zeusys 09-01-2011 03:05 PM

Thank you
Is there any solution by using xargs command?

T3RM1NVT0R 09-01-2011 03:16 PM

@ Reply
 
Yes there is a way but a bit confusing. The one mentioned above is easy. If you still want to try then following is the command:

Code:

find / -name name_of_destination_directory -print | xargs /bin/cp -arv source_directory1_with_full_path source_directory2_with_full_path source_directory3_with_full_path


All times are GMT -5. The time now is 08:03 PM.