I have a slow bash script which I would like to replace with awk, if possible to achieve the following.
The input file has 3 columns. Date, FQDN and a Label. The Labels can be replaced by a Flag if a condition is met.
The input file has a row for each site (FQDN) with a label on that day. The output file has 1 row / day and the sites are transposed/moved to the columns.
LABELS
- low
- mid
- high
- nil # when site has -le 2 labels in total and no label on this day
- null # when site has -gt 2 labels in total and no label on this day
FLAGS
- init # first and only value
- warn # 30 consecutive days with null - so null label is replaced with warn flag
input_data:
DATE FQDN LABEL
2025-12-01 www.site_1.tld high
2025-12-02 www.site_1.tld low
2025-12-03 www.site_1.tld mid
2025-12-03 www.site_2.tld low
2025-12-04 www.site_1.tld high
2025-12-04 www.site_2.tld high
2025-12-04 www.site_3.tld init
output_data:
DATE www.site_1.tld www.site_2.tld www.site_3.tld
2025-12-01 high null nil
2025-12-02 low null nil
2025-12-03 mid low nil
2025-12-04 high high init
. . . .
. . . .
2026-01-13 high low null
2026-01-14 null high warn ( found 30 consecutive nulls therefor warn flag )
Is there any chance to achieve this with awk?