how to rename files you put into a tar archive using linux 'tar'

前端 未结 4 1149
梦谈多话
梦谈多话 2021-01-03 21:32

I\'m trying to create a tar archive with a couple files, but rename those files in the archive. Right now I have something like this:

tar -czvf file1 /some/p         


        
4条回答
  •  误落风尘
    2021-01-03 21:36

    After not liking any solution that I've found, I've just written tarlogs.py, which lets you specify arbitrary names for tar entries. Each tar entry is constructed from one (or several) regular (or gzipped) inputs. You can also add directories, which will be recursed into as with regular tar. So in your case,

    tarlogs.py -o file1 -i /some/path/to/file2 -o file2 -i file3 -o path/to/renamedFile3 -o /etc >output.tar
    

    (-o with no -i inputs simply uses the output path as input, with no renaming)

提交回复
热议问题