having two columns, A and B.. i need to add another column C in a file and calculate the percentage based on the column A and B. (COLUMN B/ COLUMN A *100) . "|" is delimiter separating the A and B.. need C column with the percentage value. Thanks for your help
Please show us a sample input file, the corresponding output file you are hoping to produce, and whatever awk code you have tried to use to solve this problem on your own.
I don't understand what the 4th and 5th fields in the first line of your desired output are supposed to be (nor why having mismatched parentheses in your output is desirable)???
Are the <space>s at the end of field 2 in your output present in your input file? If not, why are they present in your output file? Is your output field separator just a vertical bar character ( | ) or is there some reason why field 2 and field 3 in your output are separated by a variable number of <space>s and a vertical bar character? And, why are the 4th and 5th fields separated by varying numbers of <space>s instead of by vertical bar characters?
will give you what you want? (Note that this assumes that all <space>s in fields 1 and 2 should be deleted, while the code Ravinder suggested only deletes trailing <space>s in those two fields.)