Results 1 to 6 of 6

Thread: How to copy hidden files using CLI (cp and/or tar commends)

  1. #1

    Default How to copy hidden files using CLI (cp and/or tar commends)

    Just a quick question:

    How would I copy ONLY hidden files using (a) the cp, and (b) the tar commands in the command line?

    I've been trying to brush up on CLI a bit, but I can't figure this one out ...

    Cheers,

    homoludens

  2. #2
    Join Date
    Jun 2008
    Location
    The English Lake District. UK - GMT/BST
    Posts
    36,733
    Blog Entries
    20

    Default Re: How to copy hidden files using CLI (cp and/or tar commen

    cp /home/*username/.*filename <to location>

    eg: from my terminal
    cp /home/kernelcruncher/.xsession-errors /home/kernelcruncher/bin
    Leap 15.1_KDE
    My Articles Was I any help? If yes: Click the star below

  3. #3

    Default Re: How to copy hidden files using CLI (cp and/or tar commen

    Thanks, but what about copying several files? (For example, all files starting with "K",or all hidden files in a given directory?)
    In these cases, the placeholder ".*" doesn't seem to work as all files are copied, not just the hidden ones.

    homoludens

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

    Default Re: How to copy hidden files using CLI (cp and/or tar commen

    Most hidden files are of the form .[A-Za-z]*, so you can use this glob:

    Code:
    cp .[A-Za-z]* destination-directory
    If you have numeric dotfiles, then add 0-9 to the brackets.

  5. #5

    Default Re: How to copy hidden files using CLI (cp and/or tar commen

    Thanks!

    What about, for example, copying ALL FILES EXCEPT files 1-n? (e.g. all except .kde, .kde4)

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

    Default Re: How to copy hidden files using CLI (cp and/or tar commen

    Try a glob like:

    Code:
    .[^.1-n]*

Tags for this Thread

Posting Permissions

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