Você pode usar o gawk que tem as funções strftime e mktime ( link ).
gawk -F ',' '{a[$1] += $2} END{for (i in a) print "On " strftime("%a, %d.%m.%Y", mktime( substr(i,1,4) " " substr(i,5,2) " " substr(i,7,2) " 0 0 0" )) " you spend: "a[i] " hour(s)" }' files.csv
Mais detalhes:
gawk -F ',' '
{
a[$1] += $2
}
END{
for (i in a) {
# mktime needs a date formated like this "2017 12 31 23 59 59"
# strftime needs a Unix timestamp (produced by mktime)
print "On " strftime("%a, %d.%m.%Y", mktime( substr(i,1,4) " " substr(i,5,2) " " substr(i,7,2) " 0 0 0" )) " you spend: "a[i] " hour(s)"
}
}' files.csv
Com um awk básico, você precisa chamar o comando e ler o resultado com getline :
awk -F ',' '{a[$1] += $2} END{ for (i in a) { COMMAND = "date +\"%a, %d.%m.%Y\" -d " i ; if ( ( COMMAND | getline DATE ) 0 ) { print "On " DATE " you spend: "a[i] " hour(s)" } ; close(COMMAND) } }' files.csv
Mais detalhes:
awk -F ',' '
{
a[$1] += $2
}
END{
for (i in a) {
# Define command to call
COMMAND = "date +\"%a, %d.%m.%Y\" -d " i
# Call command and check that it prints something
# We put the 1st line of text displayed by the command in DATE
if ( ( COMMAND | getline DATE ) > 0 ) {
# Print the result
print "On " DATE " you spend: "a[i] " hour(s)"
}
# Close the command (important!)
# Your child process is still here if you do not close it
close(COMMAND)
}
}' files.csv