The dateblock variable is mmddyy, two digits for hour, and EST or EDT.
When I run this command, the lines that have 5 fields and begin with a period are changed as follows, but the 4th field that I meant to update does not appear at all:
I have tried various things with sub and gsub, including a less-specific regular expression, and that didn't work either. I'm very new to awk, so trying to figure this out has been a good learning experience, but I'm hoping to "cut to the chase" now... Any help appreciated. Thanks!
I defined dateblock earlier in the program, before the awk statement. Unfortunately, the desired hour number is not just system time, but one of (02, 08, 14, 20) under EDT and (01, 07, 13, 19) under EST. I have code earlier in the program that figures out which one is appropriate based on the current system time.
I was under the impression that gsub would make the substitutions in the matching lines in the input file itself, but that the output would contain both the changed and unchanged lines. All I've been able to make it do so far is output the lines it changes. By chance are there any switches in gsub that might make it do what I want, or do I need to figure out some other way to make it pick up the additional unchanged lines in the proper order?
I have been unable to find documentation to tell me how that works exactly -- it seems to print the entire file as well as the changed lines. I can get rid of the duplicates with uniq, but since I need to run a similar command on the same file 4 times, is there a way to have it only print the entire file once?
it should print the entire file once with the changed fields. It works fine on your sample data in the original post.
Please show WHAT you have and HOW do you run it.