I'm trying to combine two options for creating a tar archive, but they don't work well together. I don't know what's the problem.
I use:
tar -C /var/www/website html -cvzf html.tgz -T /tmp/htmllist.txt
If I use only the -C option it creates a tar archive with only a relative path "./html/", but ALL the files inside that folder. I don't want this.
Then if I use only the -T option it creates a tar archive with only the required files, but the path is absolute "/var/www/website/html/whatever.html". I don't want this either.
I want a combination of the two, but somehow it doesn't work.
The folder structure is:
/var/www/website/html/
- Lots of .html files
The /tmp/htmllist.txt folder contains lines like:
- /var/www/website/html/file1.html
- /var/www/website/html/file5.html
- /var/www/website/html/file32.html
And so on.
How do I solve this problem?
cd /var/www/website
and use relative file paths in/tmp/htmllist.txt
thentar
will use relative paths in the archive. You can also usefind
and pipe the output totar ... -T -
.