Re: OT (ish): How to copy hidden files/directories

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Scot L. Harris wrote:
On Sat, 2004-10-09 at 03:47, CB wrote:

I can't figure out how to do this: copy (or move) all the hidden files
and directories contained in one directory to another directory.

Is it as embarrasingly simple as I imagine it must be?


cp .* /newdirectory

That will copy all hidden files (files that start with .) to a new
directory.

You can combine that with other options of cp. Check the man for cp page for those.


This is a really bad example. .* will also copy . and .. If you want to make sure that you only copy the dot files in a directory you want to use the command:

cp -Ra .??* /newdirectory

The -R tells it to recursively copy directories
The -a  tells archive (keeps permissions and such).

This will guarantee that .. is not copied as well.

If you want to copy everything from one directory to another
you and also use tar and rsync.  Rsync is probably the best

rsync -a /path/directory to copy /path_where_directory_to_go

If you want to copy the contents of dira to dirb:

rsync -a dira/ dirb


Mike -- Usenix member http://www.usenix.org Sage member http://www.sage.org Registered Linux User #362275 http://counter.li.org


[Index of Archives]     [Current Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Yosemite News]     [Yosemite Photos]     [KDE Users]     [Fedora Tools]     [Fedora Docs]

  Powered by Linux