I have data with an hour value and would like to copy just the hourly value from the date column to a new column. Given:
01/02/2021 07:00,54596894,0,SIEA
01/02/2021 09:00,55038801,0,SIEA
01/02/2021 06:00,55038845,0,SIEA
01/02/2021 02:00,78434342,0.004,SIEA
01/02/2021 15:00,78434429,0,SIEA
01/02/2021 17:00,78434838,0.005,SIEA
01/02/2021 05:00,78508079,2.715,SIEA
01/02/2021 19:00,79083881,0,SIEA
01/02/2021 12:00,82928135,0,SIEA
01/02/2021 01:00,83889954,0,SIEA
I would like the result to be:
01/02/2021 07:00,54596894,0,SIEA,07
01/02/2021 09:00,55038801,0,SIEA,09
01/02/2021 06:00,55038845,0,SIEA,06
01/02/2021 02:00,78434342,0.004,SIEA,02
01/02/2021 15:00,78434429,0,SIEA,15
01/02/2021 17:00,78434838,0.005,SIEA,17
01/02/2021 05:00,78508079,2.715,SIEA,05
01/02/2021 19:00,79083881,0,SIEA,19
01/02/2021 12:00,82928135,0,SIEA,12
01/02/2021 01:00,83889954,0,SIEA,01
I've been working with awk but have only been able to get it to give me the first part of the column. I need to get what's after the space and only two characters after the space. Copy end of string and paste to new column
awk '{n=split($1,a," "); print $0","a[n]}'
produces
01/02/2021 07:00,54596894,0,SIEA,01/02/2021
01/02/2021 09:00,55038801,0,SIEA,01/02/2021
...
I'm ok if I get all the characters after the space (though I'd prefer only to get the two immediate characters) but I can't seem to figure out how to get it to select the other side of the split.