Bol*_*wyn 6 deployment bash pipe tar
我试图从程序输出中添加一个文件到tar存档,而不是先在磁盘上生成它.想一想VERSION构建脚本运行时自动生成的文件.我试过这个但是解除引用的符号链接只是一个命名管道,而不是常规文件:
$ date +%s | \
tar cf test.tar \
--dereference \
--transform="s#/proc/self/fd/0#VERSION#" \
/proc/self/fd/0 \
other_files \
and_folders/
Run Code Online (Sandbox Code Playgroud)
结果应该是VERSION在tar存档内部有时间戳的文件,无需在本地生成文件:
$ tar tf test.tar
VERSION
other_files
and_folders
Run Code Online (Sandbox Code Playgroud)
我不知道如何在 TAR 存档中创建“假”文件条目。我会创建一个普通文件,将其添加到存档中,然后将其删除。
不过,您可能想尝试该选项-A(或--concatenate)。这将允许您在 中创建文件/tmp,将其添加到 TAR 存档中,然后在第二步中附加其余文件。这样,您就可以为 VERSION 文件创建任意路径。