Say I have a directory of files at
and I want to create a tar with only "dir1" as the leading directory:
I know I can first cd to the directory
cd /home/user1/ tar czvf dir1.tar.gz dir1
But when writing scripts, jumping from directory to directory isn't always favorable. I am wondering is there a way to do it with absolute paths without changing current directories?
I know I can always create a tar file with absolute paths INSIDE and use
when extracting but sometimes extra path names are extra private information that you don't want to distribute with your tar files.