I have a csv file in the following format:
20171129,1
20171201,0.5
20171201,0.5
20171202,1.25
20171202,1.75
I use the following command to sum up the second field if it is following the same date with this command:
awk -F ',' '{a[$1] += $2} END{for (i in a) print "On " i, "you spend: "a[i] " hour(s)"}' << "file.csv"
the output I get looks like this:
On 20171129 you spend: 1 hour(s)
On 20171201 you spend: 1 hour(s)
On 20171202 you spend: 3 hour(s)
what I want to achieve now is format the date as if I would with:
awk -F ',' '{a[$1]} END{for (i in a) print i}' << "file.csv" \
| date +"%a, %d.%m.%Y" -f -
# prints:
MiWed, 29.11.2017
FrFri, 01.12.2017
SaSat, 02.12.2017
so my final result would look like:
On MiWed, 29.11.2017 you spend: 1 hour(s)
On FrFri, 01.12.2017 you spend: 1 hour(s)
On SaSat, 02.12.2017 you spend: 3 hour(s)
is it possible to invoke date within the awk command to format the output?