我需要在 bash 中對 .tar 做一些簡單的壓縮多個檔案。條件:我的存檔必須只包含擴展名為 .exe 的檔案。不幸的是,當我嘗試這個時:
find ./myDir -name "*.exe" | tar -cf archive -T -
檔案名更改為 ./file1.exe 如何在不更改檔案名的情況下壓縮它?
uj5u.com熱心網友回復:
建議:
find "$PWD/myDir" -name "*.exe" | tar -cf archive -T -
這不會做任何有趣的事情。
更好地建議使用tar命令的結果來提供find命令
tar czf your_compressed_file.tar.gz $(find ./myDir -name "*.exe")
通知tar cf未壓縮。但是tar czf被壓縮了。
您還可以添加-v選項以查看壓縮檔案是什么:
tar czfv your_compressed_file.tar.gz $(find ./myDir -name "*.exe")
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/447750.html
