4 ms·
Just yesterday I was able to write a one liner on the command line to analyze my skype usage. I wanted to see if it was making financial sense to keep skype alo
by twistedanimator 14y ago
Just yesterday I was able to write a one liner on the command line to analyze my skype usage. I wanted to see if it was making financial sense to keep skype alongside my prepaid wireless plan.
You can download your last six months of skype activity from skype.com and they are in the form:
Date;Date;Item;Destination;Type;Rate;Duration;Amount;Currency
"July 31, 2012 21:16";"2012-07-31T21:16:01+00:00";"+11234567890";"USA";"Call";0.000;00:00:10;0.000;USD
"July 31, 2012 21:15";"2012-07-31T21:15:38+00:00";"+11234567890";"USA";"Call";0.000;01:17:02;0.000;USD
After 15 minutes or so, I came up with the following one liner:
cut -f7 -d";" call_history* | grep -v "Duration" | awk '{ FS=":"; s+=$1*60; s+=$2; if ($3 != 00) { s+=1 } } END {print s " minutes"}'
I could have done the same thing in perl or python in 5 minutes, but it was interesting to "program" only by hooking programs together to achieve the same thing.
After analyzing my skype logs, I found I used 1800 minutes. That would have cost me $180 with prepaid minutes, but only cost $30 with skype.
- ralph 14y agoAnother way would be all awk. awk -F\; ' $7 != "Duration" { split($7, t, ":") s += t[1] * 60 + t[2] + (t[3] != 0) } END {print s + 0} ' Note the handling of s == "" in END.
- ralph 14y agoThe sed and dc combo are perhaps not as readable, but there was a time before the dawn of the One True Awk. :-) sed '1s/.*/0/; s/;[^;]*$//; s///; s/.*;// s/00$//; s/:..$/+1++/; s/:$/++/; s/:/ 60*/; $s/$/p/' | dc