Using bash/terminal to get number of battery recharge cycles
Solution 1:
Something like
system_profiler SPPowerDataType | grep "Cycle Count" | awk '{print $3}'
should do the job.
system_profiler SPPowerDataType | grep "Condition" | awk '{print $2}'
will get you the battery condition, for example: Normal
.
If you want more output, run:
system_profiler SPPowerDataType | grep -A3 -B7 "Condition"
to get something similar to this:
Charge Information:
Charge Remaining (mAh): 2405
Fully Charged: No
Charging: No
Full Charge Capacity (mAh): 3816
Health Information:
Cycle Count: 187
Condition: Normal
Battery Installed: Yes
Amperage (mA): -2635
Voltage (mV): 11212