我需要一个工具来打印 plist 文件中的实际文本(plutil 更改格式,cat 打印乱码,并且 iOS 没有默认命令)。它需要位于脚本中,因此文本编辑器不起作用。
这就是我需要它的目的:
apps="$(find /var/mobile/Applications -name "Info.plist" | grep "\.app/Info\.plist")"
mkdir /var/mobile/rmnames
for app in $apps; do
newplist="$(echo $app | sed 's|/var/mobile/Applications/[^/]*/||' | sed 's|\.app/Info\.plist|.txt|')"
#1# $app | sed 's|<string>#2#</string>|<string></string>|' > "/var/mobile/rmnames/"$newplist
mv "/var/mobile/rmnames/"$newplist $app
done
rm -rf /var/mobile/rmnames
我希望这样做是删除我的跳板上的所有应用程序商店应用程序名称,而无需手动执行。其中“#1#”是 plist 打印实用程序,“#2#”是用于查找 CFBundleDisplayName 的正则表达式。
另外,如果你想知道为什么我不做一个 Cydia 调整来做到这一点,我鄙视 Mobile Substrate.. 哈哈,提前谢谢!
我所说的胡言乱语的意思的例子:
mobile:Flixster.app> cat Info.plist
bplist00?#
!"#$%&'()*+,(4567(9:; <=>CDEVWXY[\]^_bc_CFBundleSignatureYDTSDKName_DTPlatformBuild_BuildMachineOSBuil d_UIPrerenderedIcon_MedialetsUseTestServers_CFShortVersionString_CFBundleExecuta ble_CFBundleIconFiles_LSRequiresIPhoneOS]NSMainNibFile^MedialetsAppID_CFBundlePackageTypeZDTSDKBuild_UIRequiresPersistentWiFi\DTXcodeBuild_NSMainNibFile~ipad_CFBundleResourceSpecificationZDTCompiler_CFBundleDisplayName_%UISupportedInterfaceOrientations~ipad_CFBundleDevelopmentRegion^DTPlatformName_CFBundleURLTypes\CFBundleName_CFBundleVersion_DTPlatformVersion_CFBundleSupportedPlatformsWDTXcode_FLXReleaseCandidate_MinimumOSVersion_CFBundleIdentifier^UIDeviceFamily_CFBundleIconFile_CFBundleInfoDictionaryVersionT????[iphoneos5.0U9A334V10K549 T5.20XFlixster?-./012XIcon.png[[email protected][Icon-72.png_Icon-Small-50.png^[email protected] ZMainWindow_(83e69fab771f958d7de70ada6ba32ff334b9eec1TAPPLU9A334 U4C199_MainWindow-iPad_ResourceRules.plist_com.apple.compilers.llvmgcc42P??@AB_#UIInterfaceOrientationLandscapeLeft_$UIInterfaceOrientationLandscapeRight_UIInterfaceOrientationPortrait_(UIInterfaceOrientationPortraitUpsideDownUen_USXiphoneos?F?GHIJ_CFBundleURLName_CFBundleURLSchemes_com.jeffreygrossman.moviesapp? KLMNOPQRSTUXflixster\fb2558160538\fb2373897986\fb2446021478]fb55312797380\fb5769 273609\fb2352444510\fb2451978556]fb16478767641]fb87604592406\fb2532675812XFlixst erT5.20S5.0?ZXiPhoneOST0420R10S4.0_com.jeffreygrossman.moviesapp? `aXIcon.pngS6.Qeo??????(7MXs??????)<I[o???????%+2349BIR^j~?????????? 238^????????.:CP]┘│??????????????!␍%└⎺␉␋┌␊:F┌␋│⎽├␊⎼.▒⎻⎻>
答案1
您可以用来file
确定 plist 的类型以及它是否是二进制的:
plutil -convert xml1 $file && sed /*whatever*/ $file && plutil -convert binary1 $file
否则,您当然可以sed
直接在 xml 文件上使用(或 perl)。