Last active
August 1, 2025 15:47
-
-
Save selfagency/3defeb12a0df124da141652b5895fca5 to your computer and use it in GitHub Desktop.
parse apple ioreg command output
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #!/usr/bin/env bash | |
| function parseData() { | |
| tail -n +2 $1 | | |
| sed -re 's/\=/\:/g' | | |
| sed -re 's/</\"/g' | | |
| sed -re 's/>/\"/g' | | |
| sed -re 's/No/false/g' | | |
| sed -re 's/Yes/true/g' | | |
| sed -re 's/\(/\[/g' | | |
| sed -re 's/\)/\]/g' | | |
| sed '$d' | | |
| sed '$d' | | |
| sed 's/$/,/' | | |
| sed '1 s/\,//' | | |
| sed '$ s/\,//' | | |
| sed '52 s/,//' | |
| } | |
| ioreg -r -c "AppleSmartBattery" | parseData |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment