tar with relative paths
~
is expanded by the shell. Don't use ~
with -C:
tar czf ~/files/wp/my-page-order.tar.gz \
-C ~ \
webapps/zers/wp-content/plugins/my-page-order
(tar will include webapps/zers/wp-content/plugins/my-page-order
path)
or
tar czf ~/files/wp/my-page-order.tar.gz \
-C ~/webapps/zers/wp-content/plugins \
my-page-order
(tar will include my-page-order
path)
Or just cd
first....
cd ~/webapps/zers/wp-content/plugins
tar czf ~/files/wp/my-page-order.tar.gz my-page-order
-C new_cwd
changes the current working directory to new_cwd
. The following arguments are then evaluated relative to new_cwd
.
Example:
tar czf ~/files/wp/my-page-order.tar.gz \
-C ~/webapps/zers/wp-content/plugins/ my-page-order
The non GNU solution if tar
has no -z
option, just to mention:
pushd ~/files/wp; tar cvf - my-page-order | gzip > my-page-order.tar.gz && rm -rf my-page-order; popd
EDIT (with &&
and without rm
):
pushd ~/files/wp && tar cvf - my-page-order | gzip > my-page-order.tar.gz && popd