Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

9
  • 1
    Does it have to be cp? rsync usually handles those kind of sophisticated copy requirements much better. See rsync recursively with a certain depth of subfolders for example. Commented Nov 22, 2023 at 8:40
  • 2
    By the way, I assume you want to copy the 1st level directories including the files in them, just without the subfolders, is that right? Commented Nov 22, 2023 at 8:42
  • yes that's right, exclude files from all levels but exclude subfolders in the 1, 2,3,4 Commented Nov 22, 2023 at 9:44
  • 1
    Anmac1789 your response ^^ reads to me as "yes" agreeing to the first level directories being copied with their files, but then you say "exclude files from all levels". Please edit your question to state whether copying should include first level directories and their immediate files, or copying should include the first level directories only, without any files Commented Nov 22, 2023 at 10:09
  • Tar can also do what you want. Commented Nov 22, 2023 at 10:27