Sorry -- owing to lazy mouse-copying I made a mistake below.
On 14-Oct-06 cl@isbd.net wrote: If I want to copy a hierachy of files and directories which include a lot of hidden files (and directories) i.e. ones which start with '.' what is the easiest way to go about it?
I know one approach is to use tar but it would be easier if I could simply 'cp -R x y' and copy *everything* in x to y. Is there not a simple way to do this?
I think the way to do it (but there are traps, which this method tries to avoid) is cd x cp -a * .[^.]* full_path_to_y This does two things: 1. The 'cd x' avoids x itself being created as a subdirectory of y with everything under x being copied to y/x/.... 2. In "cp -a * .[^.]* full_path_to_y", the "*" matches non-hidden files (i.e. don't start with ".") and the ".[^.]*" excludes the directory x/.. (which would cause everything below the parent directory of x to be copied!). I've just tested this with two test directories ~/Test1 ~/Test2 with ~/Test2 initially empty, and ls -aR Test1 Test1: . .. a .a .A b .b c .c d .d Test1/.A: . .. a .a b .b c .c d .d so there's a mixture of hidden and visible files in Test1, and a hidden directory .A with a similar mixture. After cd Test1 #### cp -a * .[^.]* full_path_to_y #### NO!!! cp -a * .[^.]* ../Test2 cd .. I find that ls -aR Test2 gives: ls -aR Test2 Test2: . .. a .a .A b .b c .c d .d Test2/.A: . .. a .a b .b c .c d .d which is identical to Test1. But I suggest you test this for yourself, and see if it does exactly what you want! (It's tricky). Best wishes, Ted. -------------------------------------------------------------------- E-Mail: (Ted Harding) <Ted.Harding@nessie.mcc.ac.uk> Fax-to-email: +44 (0)870 094 0861 Date: 14-Oct-06 Time: 22:53:58 ------------------------------ XFMail ------------------------------