重定向分割輸出

重定向分割輸出

gunzip我使用管道分割了一個 gz 檔split

time gunzip -c file.gz | split -l 500 -d -a 4 - pref_

它會產生以下文件:

pref_0000 
pref_0001

我想透過管道傳輸這些檔案以再次壓縮它們。我嘗試了以下方法:

gunzip -c file.gz | split -l 500 -d -a 4 - pref_ | echo "file produced:" -
# Nothing

gunzip -c file.gz | split -l 500 -d -a 4 - pref_ | echo -
gunzip -c file.gz | split -l 500 -d -a 4 - pref_ | echo

這些不起作用,我如何獲得 split 命令的輸出?我希望獲得產生的檔案名稱。

答案1

你可以使用- 篩選在每個分割檔案上split調用的選項zip

gunzip -c file.gz | split -l 500 -d -a 4 - pref_ --filter='zip $FILE'

相關內容