Results 1 to 4 of 4

Thread: Problem copying hidden files with cp

  1. #1
    Join Date
    Mar 2008
    Location
    Oz
    Posts
    11,727
    Blog Entries
    2

    Default 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
    Leap 42.3 & 15.1(Beta) &KDE
    FYIs from the days of yore

  2. #2
    Join Date
    Mar 2008
    Location
    Vsters, Sweden ex. Highbury London UK
    Posts
    1,245

    Default Re: Problem copying hidden files with cp

    Maybe this may help.
    did a quick google and got loads of hits

    Geoff
    Core 2 Duo 3.16GHz, 8GB DDR2, 3.5TB, GeForce 9600 GT, Amilo LCD 26", OS 11.1 x86_64, KDE4.2.4 (2)
    My wine tips & tricks

  3. #3
    Join Date
    Jun 2008
    Location
    UTC+10
    Posts
    9,686
    Blog Entries
    4

    Default Re: Problem copying hidden files with cp

    Quote Originally Posted by swerdna View Post
    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/.

  4. #4
    Join Date
    Mar 2008
    Location
    Oz
    Posts
    11,727
    Blog Entries
    2

    Default Re: Problem copying hidden files with cp

    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.
    Leap 42.3 & 15.1(Beta) &KDE
    FYIs from the days of yore

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •