Ask Different is a question and answer site for power users of Apple hardware and software. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to get the number of recharge cycles using bash (terminal commands). I understand the following command will display all of the battery data, but I want the cycle count on its own

ioreg -l -w0 |grep Capacity

I use the following command to get the battery percentage, so I imagine it can be modified slightly to get the cycle count instead;

ioreg -l | awk '$3~/Capacity/{c[$3]=$5}END{OFMT="%.3f";max=c["\"MaxCapacity\""];print(max>0?100*c["\"CurrentCapacity\""]/max:"?")}'

I'm new to bash, so I'm not completely sure how that code works, or how I'd adapt it for my needs.

Any help would be appreciated. Thanks.

share|improve this question
up vote 10 down vote accepted

Something like

system_profiler SPPowerDataType | grep "Cycle Count" | awk '{print $3}'

should do the job.

share|improve this answer
Thank you for your help. That works perfectly :) – user2370602 Jan 8 '14 at 16:07

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.