Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Not sure if it's common across all tar implementations, but you can use -C to let GNU tar change directories before performing any operation. So this command is equivalent:

  $ tar -cC /source/dir . | ssh rhost tar -xvC /dest/dir
(I also left out -f - because it's the default)


Helpful, thanks. Old habits die hard. Tar wasn't always GNU tar back when this became useful to me.


FWIW, while tar isn't even a POSIX command, -C is supported by bsdtar[1] (including macOS), AIX tar (confirmed AIX 7.1), and Solaris tar (confirmed Solaris 11.4). Argument ordering and bundling is really funky on AIX and Solaris, though, especially for extraction.

[1] Seems like everybody except OpenBSD has migrated to libarchive's bsdtar, but OpenBSD also supports -C.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: