LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   Copying directories (https://www.linuxquestions.org/questions/linux-newbie-8/copying-directories-21728/)

NetScripter 05-24-2002 09:17 AM

Copying directories
 
How can I copy all directories except one which name is known?
All directories is on the same level.
Please help

vfs 05-24-2002 09:27 AM

Try:

for i in ./*
do
if [ "$i" != "known_dir" ]; then
cp -a $i /destination
fi
done

Forgive me if I misunderstood.

HTH,

vfs

NetScripter 05-25-2002 12:10 AM

thanks

Camion 05-25-2002 12:48 AM

Hi,

If your containing directory is not too large, you can also type cp -a [ESC]* Destination... at the time you type [ESC]*, it expanded (with bash) in the name of all the contained file and folders, then you remove the one you don't want from the list.

Another way, which uses grep is by using the cpio command :
find . | grep -v '/dir_name_you_don_t_want/' | cpio -pdumV dest_dir


All times are GMT -5. The time now is 04:57 PM.