$ touch a b c $ tar -caf ./mytar.tgz --transform='s#^#mydir/#s' a b c $ tar -tf ./mytar.tgz mydir/a mydir/b mydir/c $