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*

5
  • Related: How to prevent mv from moving a collection of files into a single regular one? Commented Sep 9, 2015 at 16:15
  • 2
    Some of those options aren't POSIX, so the ones you tried aren't very portable. If you can live with a little lack of portability, why not use rsync? Commented Sep 9, 2015 at 22:47
  • 2
    If you don't need to use cp, piping between two tar commands is a nice reliable way to copy trees. Commented Sep 10, 2015 at 3:39
  • @R.. can you provide an example? @muru I'd like this to work in MINGW which does not have rsync shipped. Commented Sep 10, 2015 at 8:21
  • 1
    With GNU tar, tar -C input -cf - . | tar -C output -xf - works. -C changes working directory, but it is not a standard option, so if it's not supported you need to run the two tars in the right working directories to begin with, e.g. ( cd input && tar -cf - . ) | ( cd output && tar -xf - ) However if you're dealing with Windows I would just use roaima's answer. Commented Sep 10, 2015 at 14:36