LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Copying Hidden Directories (https://www.linuxquestions.org/questions/linux-general-1/copying-hidden-directories-122996/)

Guru3 12-05-2003 12:45 PM

Copying Hidden Directories
 
I am making a backup of my home directory, and when I tried like cp -ar * /home/home-bkup and it didn't copy those directories that start with a . and my question is how do I do that?

wapcaplet 12-05-2003 12:59 PM

Check out this post. Tricky, but it should work :)

So I guess the command you'd want is:

cp -ar * .[^.]* /home/home-bkup

The junk with the brackets just tells cp to also copy anything beginning with a dot, but not beginning with two dots (to prevent it from copying everything in the parent directory also). The same technique can also be used with rm, to remove hidden files, but be careful with it in that case, especially if you are running as root! You could very easily remove a whole bunch of stuff you didn't mean to.


All times are GMT -5. The time now is 05:42 PM.