Problem copying hidden files with cp

Hi. I’m cleaning off space on my sda drive, so:
I’m backing up my personal home directories from an old 10.3
installation on the the origin drive sda8 to a backup drive sdb where
I’ve made a directory /JOHN103. The command is this, issued in a console
as root user:

Code:

cp -a /mnt/sda8/john/* /mnt/sdb2/JOHN103

That works fine except it doesn’t copy the hidden files. I thought the
“-a” option would copy hidden files, after all “-a”, the archive option,
means “-dpR”.

What am I missing?

Thanks
Swerdna


‘Come visit sometime’
(http://www.swerdna.net.au/linux.html)

swerdna’s Profile: http://forums.opensuse.org/member.php?userid=84
View this thread: http://forums.opensuse.org/showthread.php?t=401651

Maybe 'this ’ (http://tinyurl.com/6nb2ar)may help.
did a quick ‘google’ (http://tinyurl.com/6cnupf) and got loads of hits

Geoff


Core 2 Duo E8500 3.16GHz - 4GB DDR2 - 1.8 TB - GeForce 7600 GS - OS 11
x86_64 - KDE 4.182 (release 3.1)

geoffro’s Profile: http://forums.opensuse.org/member.php?userid=75
View this thread: http://forums.opensuse.org/showthread.php?t=401651

swerdna;1907705 Wrote:
> Hi. I’m cleaning off space on my sda drive, so:
> I’m backing up my personal home directories from an old 10.3
> installation on the the origin drive sda8 to a backup drive sdb where
> I’ve made a directory /JOHN103. The command is this, issued in a console
> as root user:
> >
Code:

> > cp -a /mnt/sda8/john/* /mnt/sdb2/JOHN103

> >
> That works fine except it doesn’t copy the hidden files. I thought
> the “-a” option would copy hidden files, after all “-a”, the archive
> option, means “-dpR”.
>
> What am I missing?
>
> Thanks
> Swerdna

The problems is that the wildcard * only matches non-hidden files.

To get what you want, copy the directory:

Code:

cp -a /mnt/sda8/john/. /mnt/sdb2/JOHN103

Notice the . after john/.


ken_yap

ken_yap’s Profile: http://forums.opensuse.org/member.php?userid=221
View this thread: http://forums.opensuse.org/showthread.php?t=401651

From Geoff I hunted down this solution:
shopt -s dotglob
cp -a /mnt/sda8/john/* /mnt/sdb2/JOHN103
shopt -u dotglob
But clearly Ken’s is the way to go.

Thanks guys.


‘Come visit sometime’
(http://www.swerdna.net.au/linux.html)

swerdna’s Profile: http://forums.opensuse.org/member.php?userid=84
View this thread: http://forums.opensuse.org/showthread.php?t=401651