Extracting Cycle Count From System Report
I have an automator action set up to generate a Power System Report and create a text file based on it. Is there any way I can extract the Cycle Count from this?
OS X Yosemite (10.10.3)
I have an automator action set up to generate a Power System Report and create a text file based on it. Is there any way I can extract the Cycle Count from this?
OS X Yosemite (10.10.3)
From the Terminal:
$ system_profiler SPPowerDataType | awk '/Cycle Count/ {print $3}'
Return: 96 (on my 2014 MacBook Air)
From the Terminal:
$ system_profiler SPPowerDataType | awk '/Cycle Count/ {print $3}'
Return: 96 (on my 2014 MacBook Air)
Hi techteej, I think I'm trying to create roughly the same thing.
I'm using Automator, and the following;
[system_profiler SPPowerDataType | awk '/Cycle Count/ {print $3}']
returns;
567
I'm looking to add the date it was run, like a time/datestamp, to return a result like this;
567, dd/mm/yyyy
I'm not an expert in this area, so any help would be gratefully received.
Using OS X 10.11.4 (El Capitan)
date "+%d/%m/%Y"
returns
"25/05/2016"
Thanks Viking for the quick response.
Because I'm not an expert, the results (for the date) appear on a second line, how do I get them to be in the same line? What's the correct structure or syntax?
I get;
567
25/05/2016
I would like;
567 25/05/2016
I would like this so i can import my text file into excel at a later stage.
temp=$(system_profiler SPPowerDataType | awk '/Cycle Count/ {print $3}'); echo "$temp $(date "+%d/%m/%Y")"
Result: nnn 25/05/2016
A cleaner solution where awk handles printing all the output:
system_profiler SPPowerDataType | awk -v today="$(date "+%d/%m/%Y")" '/Cycle Count/ {print $3, today}'
Thanks Mark, for cleaning up my act. 😉
Viking, Mark, thanks for your time on this. I've modified it slightly and it's just the job.
temp=$(system_profiler SPPowerDataType | awk '/Cycle Count/ {print $3}')","; echo "$temp$(date "+%d/%m/%Y")"
and it returned
592,26/05/2016
I now run this daily using a scheduled 'Automator' job and it writes to a log. I can then see how quickly I'm approaching my 1000 cycles for a MacBook Pro.
Extracting Cycle Count From System Report