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.

3
  • thanks and if I want to exclude a specific directory ? Commented Mar 3, 2022 at 17:00
  • 1
    Since the question is tagged "Linux" they should be able to use GNU find's -printf '%h\n' (or better, -printf '%h\0' with sort -zu) to get the leading path components, which avoids the shell loop - see Why is looping over find's output bad practice? Commented Mar 3, 2022 at 17:17
  • Try after mkdir -p 'foo /*/*/*/* *.txt' for instance. Commented Mar 3, 2022 at 18:18