You can do it without the loop. Assign your timestring back into $1 and set $2='' (nullstring). Then just "print" will dump the entire revised line.
1
1
Or use IFS to make things cleaner:
IFS='. '; cat access.log | while read time frac rest; do echo $(date -d @$time "+%FT%T").${frac}Z $rest; done
May 4, 2021 · 2:06 PM UTC
