I am trying to write an awk program to reformat a data table and convert the date to julian time. I have all the individual steps working, but I am having some issues joing them into one program. Can anyone help me out? Here is my code so far:
# This is an awk program to convert the dates from time series data to Julian dates.
#
# 1. Remove leading "1" from every line
#
{sub(1,"",$1); #print}
#
# 2. Change single digit months to MM
#
sub(/^[ \t]+/,0); #print} #### works up to here if i comment everything following out ####
#
# 3. Change single digit days to DD
#
if ( NF == 37 ) sub(/^[ \t]+/,0,2); #print}
else if ( NF == 38 ) sub(/^[ \t]+/,0,2) && sub(/^[ \t]+/,0,3);
print} ### This is what I can't get working so far ###
#
Here is an example of the date part of the data:
110/24/74FDUNC
110/24/74FDUNC
110/25/74FDUNC
1 3/ 3/75FDUNC
1 3/ 3/75FDUNC
1 3/ 3/75FDUNC
step one as it says in the code removes the leading "1", step 2 adds a "0" to the single digit months and step 3 is suppose to add a "0" before the single digit days and years.
Right now I can get step 1 and 2 to run together, but I can't get step 3 to do anything. There are more steps after this, but not much use trying to get them to work until I get the first stuff to work. Thanks in advance.