Can you have tar travel to a certain direct and then tar files relative to that directory? All while using one command (tar)?
你有焦油旅行到某个直接,然后相对于该目录的tar文件?所有使用一个命令(焦油)?
For example instead of doing
例如,而不是做
cd /home/test/backups; tar zvPcf backup.tar.gz ../data/
I could do something like
我可以做点什么
tar -g '/home/test/backups/' zvPcf backup.tar.gz ../data/
4 个解决方案
#1
6
Have you tried this:
你试过这个:
tar zvPcf /home/test/backups/backup.tar.gz /home/test/backups/../data/
#2
9
see the -C option.
请参阅-C选项。
the tar man page gives this example :
tar手册页给出了这个例子:
tar -xjf foo.tar.bz2 -C bar/
extract bzipped foo.tar.bz2 after changing directory to bar
might be what you're looking for ...
可能是你在寻找...
#3
1
You could try:
你可以尝试:
tar zvPcf backup.tar.gz ../data/ -C '/home/test/backups/'
tar zvPcf backup.tar.gz ../data/ -C'/ home / test / backups /'
#4
1
See tar(1) man page.
请参见tar(1)手册页。
-C, --directory DIR
change to directory DIR-C, - 目录DIR更改为目录DIR
#1
6
Have you tried this:
你试过这个:
tar zvPcf /home/test/backups/backup.tar.gz /home/test/backups/../data/
#2
9
see the -C option.
请参阅-C选项。
the tar man page gives this example :
tar手册页给出了这个例子:
tar -xjf foo.tar.bz2 -C bar/
extract bzipped foo.tar.bz2 after changing directory to bar
might be what you're looking for ...
可能是你在寻找...
#3
1
You could try:
你可以尝试:
tar zvPcf backup.tar.gz ../data/ -C '/home/test/backups/'
tar zvPcf backup.tar.gz ../data/ -C'/ home / test / backups /'
#4
1
See tar(1) man page.
请参见tar(1)手册页。
-C, --directory DIR
change to directory DIR-C, - 目录DIR更改为目录DIR