Click to See Complete Forum and Search --> : Copying all files - including hidden ones


o0zi
08-29-2004, 06:16 AM
Probably showing my ignorance here, but how exactly do you copy all the files in a directory, including all the ones that begin with a dot such as .bashrc?
cp .* gives errors, because it copies again and again, as .* includes ../directory/.file as well as .file. cp * doesn't copy hidden files.
Hopefully someone can enlighten me with the answer to a problem I really should've asked before ;)

ichyska
08-29-2004, 09:20 AM
I should think:

cp `ls -A` destination

will do it.

"ls -A" lists nearly all the files in the current directory, it includes dot files, but not "." or ".." . It's enclosed in backticks (above the tab key). That makes bash replace it with the output of the command.

janet loves bill
08-29-2004, 10:00 AM
cp -Rav /path/

fiske
08-29-2004, 10:01 AM
could be wrong but I would try
cp -R /directory/to/be/copied /new/directory