OK that does the trick
could you just help explain the code for me as to what each section is doing so that i may learn from this process rather thangettingthe answer.
Also one problem i am finding is that if the original file had a figure of
,,00003864096.93 it is being displayed as
,,3.8641e+06.
It is imperative that the ammount remans the same and no rounding is done, could you assist.
I didn't check what it does with such long values.
For the code:
Setting awk's input field separator to something useful. Those double commas suited well:
-F",,"
$0 !~ /Amount/ {print $1,",,"($2+$3)}
$0 -> the whole line
!~ -> is not like
/Amount/ -> is just a pattern, a string in that $0
The curly brackets start the action when "the line has nothing like "Amount" in it
print $1 -> prints the 1st field, which is defined by our separator we have set in the beginning
The comma separating $1 and ",," is putting in the OFS, output field separator which is a blank per default
",," -> simply printing two commas
($2+$3) -> adding the values of field 2 and field 3 (don't forget, the ",," counts as field separator and is left out
Thats for that action so far, so we check the current line with the next pattern/action pair
/Amount/ {print "code: Amount"}
/Amount/ {print "code: Amount"} -> if pattern "Amount" is somewhere in the line, just print out the string "code: Amount"
' infile -> hands over awk the file parse, so no "cat infile| awk ..." is needed, which is useless use of cat.