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

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

James Wilkinson wrote:
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?

Last time this came up, Ulrich Drepper pointed out the
shopt -s dotglob

This makes * match hidden and non-hidden files.

shopt -s dotglob
mv $olddir/* $newdir
will move everything, hidden and non-hidden.

Possibly the simplest way to just move hidden would then be to move back
the non-hidden. Or to move them to a safe directory first.

To move only hidden (dot-) files/folders to another directory...

# cp -pr .??* newdir

Why use ".??*" ...
  * the initial "." indicates a 'hidden' file (or dot-file in Unix parlance)
  * the "??" match at least two characters ... this keeps the pattern from
    matching ".." which is the parent-directory
  * the "*" match any number (from zero to a-lot!) of characters

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