I want to create a tar archive in a different directory rather than the current directory.
I tried this command:
tar czf file.tar.gz file1 -C /var/www/
but it creates the archive in the current directory. Why?
|
I want to create a tar archive in a different directory rather than the current directory. I tried this command:
but it creates the archive in the current directory. Why? |
|||
|
The easy way, if you don't particularly need to use The following will create the archive
The path (to either the archive, the constituent files, or both) can of course also be relative. If
There's a million variations on the theme, but this should get you started. Add the |
|||||||
|
tar czf /var/www/file.tar.gz file1should work great. – Michael Kjörling Feb 15 at 18:34-C(which is not strange as its documented vaguely). For details see serverfault.com/q/416002/86283. – N.N. Feb 15 at 18:48