我有一个压缩命令,将其作为管道输出给md5sum检查命令:
tar zcvpf file.tar.gz file | xargs -I '{}' bash -c "test -f '{}' && md5sum '{}'" | tee file_mybackup.md5
我现在想将tar.gz文件分成100MB的块。我可以通过以下方式实现:
tar zcvpf - file | split -d -b 1M - file.tar.gz.
有没有办法将tar命令的输出同时传输到split命令和md5sum检查中?我知道split不会输出到STDOUT,所以我无法从split命令传输到md5sum命令。我尝试使用命名管道:
mkfifo newpipe
tar zcvpf - file | tee newpipe | split -d -b 1M - file.tar.gz. &
cat newpipe | xargs -I '{}' bash -c "test -f '{}' && md5sum '{}'" | tee file_mybackup.md5
然而,这无法输出md5sum输出。如有帮助将不胜感激。
command | tee >(command 2) | command 3
- 123xargs
使用方法有误:你的代码存在任意代码执行漏洞! - gniourf_gniourftar zcvpf - file | tee >(xargs -I '{}' bash -c "test -f '{}' && md5sum '{}'" > file.md5) | split -d -b 1M - file.tar.gz.
但是这会出现错误:xargs: Warning: a NUL character occurred in the input. It cannot be passed through in the argument list. Did you mean to use the --null option?
如何将STDOUT重定向到xargs -I命令? - user1977981