go to path and then tar?

bash, command-line, linux, tar

Solution

Have you tried this:

tar zvPcf /home/test/backups/backup.tar.gz /home/test/backups/../data/

Problem

Can you have tar travel to a certain direct and then tar files relative to that directory? All while using one command (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/ ```

Original source