Issue
Here is an example iOS info.plist file
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleShortVersionString</key>
<string>$(MARKETING_VERSION)</string>
<key>CFBundleVersion</key>
<string>178273</string>
<key>NSExtension</key>
</dict>
</plist>
How can I grep the string value 178273 from this file from the command line? This 178273 can be a different number. The goal is to grep this value under the key CFBundleVersion
Solution
example:
cat info.plist | grep -A1 "CFBundleVersion" | grep -o "[0-9]*"
Assumption
- The target must be on the line immediately following key CFBundleVersion.
- Target must be a number. Others must not contain numbers.
Answered By - dam Answer Checked By - Marilyn (WPSolving Volunteer)