I am trying to parse a file and have a few fields that need to have character replacement done before the field is printed.
So the input file looks like this:
D10/04/2011
T$5.29
C
PA STORE
MSOMEPLACE, STATE
^
I need the ^D, ^T, and ^P to find what I want, but I then I want to set the variables so the first character (D, T, and P) are not printed.
Ex. Here's what I wrote for my awk script so far.
/^D/{date = $1}
/^T/{amount = $1}
/^P/{bill = $0}
/\^/{printf ("%-10s %-12s %-30s\n", date, amount, bill)}
I think I need to do something with sub or match, but I can't seem to get it to work.
The desired output is:
10/04/2011 $5.29 THE HOME DEPOT
Any help would be greatly appreciated.
Thanks,
John
So the input file looks like this:
D10/04/2011
T$5.29
C
PA STORE
MSOMEPLACE, STATE
^
I need the ^D, ^T, and ^P to find what I want, but I then I want to set the variables so the first character (D, T, and P) are not printed.
Ex. Here's what I wrote for my awk script so far.
/^D/{date = $1}
/^T/{amount = $1}
/^P/{bill = $0}
/\^/{printf ("%-10s %-12s %-30s\n", date, amount, bill)}
I think I need to do something with sub or match, but I can't seem to get it to work.
The desired output is:
10/04/2011 $5.29 THE HOME DEPOT
Any help would be greatly appreciated.
Thanks,
John