How do I remove the full path when doing a tar.gz compression?
27,183
tar -czf /a/b/c.tar.gz -C /e/f/g .
The -C
option makes tar
change the working directory, so you only need to add .
.
See: Changing the Working Directory – GNU tar
manual
Related videos on Youtube
Author by
Shafiul
Updated on September 18, 2022Comments
-
Shafiul over 1 year
I'm using this command to archive a directory named
g
from Java code:tar czf /a/b/c.tar.gz /e/f/g
When the tar file
c.tar.gz
is created, I find an entire pathe/f/g
then all files of theg
folder inside it. But I only want to see files under the folderg
in the compressed archive when I open it. How do I remove the folders/e/f/
in the .tar.gz file?