You'd need to replace that ~
with your home directory first. Assuming your home directory doesn't contain :
(they generally don't as otherwise they couldn't be referenced in /etc/passwd
):
(cd / &&
sed "s:^~:$HOME:" | pax -w | gzip) < file.list > file.tar.gz
Or if your tar
is the one from GNU or bsdtar
:
(cd / &&
sed "s:^~:$HOME:" | tar -T - -zcf -) < file.list > file.tar.gz
Some other tar
have -I
instead of -T
for that. star
uses a list=-
argument for that (star cvf - list=-
).
Note that in those solutions above, except for star
, if any of the files in that list are of type directory, then the whole content of those directories is included.
To archive the directory only and not its content, with pax
add the -d
option, with GNU tar
or bsdtar
the --no-recursion
one (also -n
with bsdtar
).
With star
, to include the content of the directories, add the -dodesc
option.