copy recursively except hidden directory

uray

How do I copy recursively like cp -rf *, but excluding hidden directories (directories starting with .) and their contents?

maxschlepzig

You could just copy everything with

cp -rf 

and then delete hidden directories at the destination with

find -type d -name '.*' -and -not -name '.' -print0 | xargs -0 rm -rf

Alternatively, if you have some advanced tar (e.g. GNU tar), you could try to use tar to exclude some patterns. But I am afraid that is not possible to only exclude hidden directories, but include hidden files.

For example something like this:

tar --exclude=PATTERN -f - -c * | tar -C destination -f - -x

Btw, GNU tar has a zoo of exclude style options. My favourite is

--exclude-vcs

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How can I copy a hidden directory recursively and preserving its permissions?

From Dev

Copy and overwrite directory recursively

From Dev

List content of a directory except hidden files in Perl

From Dev

Create tar archive of a directory, except for hidden files?

From Dev

Copy recursively a directory excluding a subdirectory and ITS CONTENT

From Dev

Recursively copy files from one directory to another

From Dev

Recursively copy files from one directory to another

From Dev

Symlink Copy a Directory Non-recursively

From Dev

Copy filenames, and add path prefix, in a directory, recursively

From Dev

Copy files from directory recursively smallest first

From Dev

Copy all files in hadoop directory except 1

From Dev

Copy all files in hadoop directory except 1

From Dev

Bash shell copy files on the hidden directory

From Dev

Cannot recursive copy a hidden directory - UNIX

From Dev

How to copy contents of a directory recursively without maintaining the directory hierarchy?

From Dev

find modified files recursively and copy with directory preserving directory structure

From Dev

How to recursively copy files as hard links into directory preserving directory hierarchy?

From Dev

How to recursively search a directory for all files including hidden files in hidden directories, with PowerShell?

From Dev

Recursively copy a set of files from one directory to another in PowerShell

From Dev

How do I recursively copy/download a whole webdav directory?

From Dev

how to include and copy files that are in current directory to s3 (and not recursively)

From Dev

How do I copy all files recursively to a flat directory in Ruby?

From Dev

Recursively copy (and rename) files to their own same directory with another name

From Dev

How do I recursively copy/download a whole webdav directory?

From Dev

Recursively copy (and rename) files to their own same directory with another name

From Dev

Search a directory recursively for files listed in a csv, and copy them to another location

From Dev

recursively copy all files from one directory to another with exceptions

From Dev

Recursively copy a directory entirely as symlinks, preserving current symlinks

From Dev

How to copy all files in directory recursively and unzip compressed files on fly

Related Related

  1. 1

    How can I copy a hidden directory recursively and preserving its permissions?

  2. 2

    Copy and overwrite directory recursively

  3. 3

    List content of a directory except hidden files in Perl

  4. 4

    Create tar archive of a directory, except for hidden files?

  5. 5

    Copy recursively a directory excluding a subdirectory and ITS CONTENT

  6. 6

    Recursively copy files from one directory to another

  7. 7

    Recursively copy files from one directory to another

  8. 8

    Symlink Copy a Directory Non-recursively

  9. 9

    Copy filenames, and add path prefix, in a directory, recursively

  10. 10

    Copy files from directory recursively smallest first

  11. 11

    Copy all files in hadoop directory except 1

  12. 12

    Copy all files in hadoop directory except 1

  13. 13

    Bash shell copy files on the hidden directory

  14. 14

    Cannot recursive copy a hidden directory - UNIX

  15. 15

    How to copy contents of a directory recursively without maintaining the directory hierarchy?

  16. 16

    find modified files recursively and copy with directory preserving directory structure

  17. 17

    How to recursively copy files as hard links into directory preserving directory hierarchy?

  18. 18

    How to recursively search a directory for all files including hidden files in hidden directories, with PowerShell?

  19. 19

    Recursively copy a set of files from one directory to another in PowerShell

  20. 20

    How do I recursively copy/download a whole webdav directory?

  21. 21

    how to include and copy files that are in current directory to s3 (and not recursively)

  22. 22

    How do I copy all files recursively to a flat directory in Ruby?

  23. 23

    Recursively copy (and rename) files to their own same directory with another name

  24. 24

    How do I recursively copy/download a whole webdav directory?

  25. 25

    Recursively copy (and rename) files to their own same directory with another name

  26. 26

    Search a directory recursively for files listed in a csv, and copy them to another location

  27. 27

    recursively copy all files from one directory to another with exceptions

  28. 28

    Recursively copy a directory entirely as symlinks, preserving current symlinks

  29. 29

    How to copy all files in directory recursively and unzip compressed files on fly

HotTag

Archive