regex - 如何从 unzip -l 的输出中获取特定路径
问题描述
我需要在 .app 文件夹之后提取 Info.plist 文件的路径。
$ unzip -l test.ipa | grep Info.plist
258 05-25-2018 11:52 Payload/test.app/CDVLaunchScreen.storyboardc/Info.plist
2197 05-25-2018 11:52 Payload/test.app/Info.plist
问题是 .app 文件夹在每个 .ipa 文件中的名称都不同。我不能 grep Payload/test.app/Info.plist
。我试过了:
$ unzip -l test.ipa | grep Payload/*.app/Info.plist
$ unzip -l test.ipa | grep "Payload/..app/Info.plist"
什么都没有。
正确的 grep 参数如何?另外,我如何只提取路径(Payload/test.app/Info.plist
)而不是整行(2197 05-25-2018 11:52 Payload/test.app/Info.plist
)?
解决方案
如果您不确定是否所有路径都以 开头Payload
,请尝试
unzip -l test.ipa | grep -P '(?<=\s)\S*Info.plist'
匹配之前的所有非空白字符Info.plist
。
推荐阅读
- spring - Spring WebFlux:WebClient + 错误后备
- c# - 使用 WSDualHttpBinding 在 WCF 服务之间共享 Windows 标识
- java - docx4j 无法正确渲染边距
- c++ - 如果未在 main 中输入隔离,则 V8 异常
- c# - 继承属性的 EntityState 保持不变
- php - PHP 会话登录控制器
- python - 将嵌套字典转换为元组列表
- jquery - 如何使 DRF ( Django-REST-Framework) 令牌保持不变,使其在每次页面刷新后不会丢失?
- angular - Angular:如何正确重置反应形式
- php - SAP 客户端的 PHP SOAP 服务器在 WSDL 中存在配置问题