System Information is a GUI for the CLI system_profiler. It's read directly from whatever system_profiler
spits out. All the work is already done for you (system_profiler
reads from many different files and executables):
!Just saw an answer posted. See @XAleXOwnZX for the exact command.
To compile that into a script within Terminal, enter text as follows. Return is supported for newlines after cat
command.
$ cat > cycle
#! /bin/bash
#Output is current cycle count of the battery
system_profiler SPPowerDataType | grep "Cycle Count" | awk '{print $3}'
^D
Now, you have the script. Press Control+D within terminal for a carriage return:
Make executable with chmod +x cycle
Test:
t$ ./cycle
4
- Move into your local bin, if it's included in your shell path. The file currently resides in your top user directory ~/
$ mv cycle ~/bin/