I have the following code from here to find the cycle count of the battery on my computer:
system_profiler SPPowerDataType | grep "Cycle Count" | awk '{print $3}'
I will enclose it in a simple app that I will put in the Utilities folder in my applications folder as follows: NameofApp.sh.app->Contents->MacOS->NameofApp.sh. I will have it open on startup by means of System Preferences->Users and Groups->Login Items.
I was hoping to use the date
command in terminal which gives output (As I'm sure you know) as Tue Oct 7 19:32:33 EDT 2014
. I was hoping to delimit the date and the cycle count so I can easily separate it in excel.
The final product I was hoping for consist of a program that upon startup, prints the date + delimiter + cycle count to a new line in a text file (On desktop).
For example,
Tue Oct 7 19:32:33 EDT 2014#776
Tue Oct 8 13:55:02 EDT 2014#776
Tue Oct 8 21:23:16 EDT 2014#777
.
.
.
.
.
Tue Dec 12 07:34:56 EDT 2015#????
I'm having trouble combining the date with the output of the program above.
Thank you in advance
Best Answer
Thanks to @MateusvSzlosek, The following one-liner works: