使用aapt dump时如何打印指定的参数 [英] how to print a specified parameter when using aapt dump
问题描述
我在这里看到命令
aapt dump badging foo.apk
打印指定包的所有详细信息.
prints all the details of the specified package.
是否可以打印任何一个属性,比如 sdkversion?类似的东西
Is it possible to print any one property, say sdkversion? Something like
aapt dump badging -sdkversion foo.apk
P.S 我在 Windows 中使用命令提示符.
P.S I'm using command prompt in windows.
编辑
我正在尝试将包名称存储在变量中.截至目前,我有这个代码
I am trying to store the package name in a variable. As of now, I have this code
@echo off
for /f "delims=" %%a in ('aapt dump badging foo.apk') do (
REM each line of the output
)
我能够检索输出的每一行.现在我必须从字符串中提取包名称.例如第一行是
I am able to retrieve each line of the output. Now I have to extract the package name from the string. For instance the first line is
包:name='com.timeplusq.noob' versionCode='15' versionName='1.5'
package: name='com.timeplusq.noob' versionCode='15' versionName='1.5'
在 for 循环的第一次迭代中检索.如何从中提取包名称.我认为字符串操作会很简单,但事实并非如此.那么如何从字符串中提取包名?
which is retrieved in the first iteration of the for loop. How do I extract the package name from it. I thought string manipulation would be straight forward, it is not. So how do I extract the package name from the string?
推荐答案
如果你在 Unix 系统上或者在 Windows 上有 cygwin,你可以试试这个命令:
If you're on a Unix system or having cygwin on Windows, you could try this command :
aapt dump badging foo.apk | grep sdkVersion | sed -E "s/^[^:]+:\'(.*)\'$/\1/"
regexp 将提取由 grep 命令选择的行的值
the regexp will extract the value of the line selected by grep command
在 Windows 系统中,您可以使用以下保存为 .cmd
的脚本:
In a Windows system, you can use the following script saved as a .cmd
:
@echo off
set property=sdkVersion:'10'
set property=%property:sdkVersion=%
set property=%property:~2,-1%
echo.%property%
这篇关于使用aapt dump时如何打印指定的参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!