7z+grep+awk:
7z l -slt lang.7z | grep "^Path = " | awk '{print $3}'
7z+grep+sed:
7z l -slt lang.7z | grep "^Path = " | sed 's/^Path= //g'
以下为探索过程
使用7zip命令行工具7za/7z时遇到一个问题,只列出归档内容的文件名? How to use 7zip command line version tool for listing only filenames?
让我试试看. Let's have a try.
7z l -slt lang.7z | more
这样一行行输出文件信息,空行分隔不同文件,十分利于grep,awk提取文件名等信息. This command displays file info one item per line such as path, size, etc. And an empty line is displayed between two different files as separator. It is now more convenient for grep and awk to parse.
把输出重定向到grep "^Path = "命令.Let's redirects the output to command grep "^Path = " with a pipe '|'.
awk:
7z l -slt lang.7z | grep "^Path = " | awk '{print $3}'
sed:
7z l -slt lang.7z | grep "^Path = " | sed 's/^Path= //g'
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。