Linux script
can anyone help in this
i have a file like 2089,success 2089,failure 2087,failure 2089,success 2087,failure. i want output like. 2089,success=2,failure=1 2087,success=1,failure=2 thanks |
Wierd! Do you want that when 2089 comes, 2 gets assigned to success and 1 to failure, similarly when 2087 comes, success gets 1 and failure gets 2?
Although it can be managed using a script, but specify that what's purpose of doing this. |
its not assigning its like script should fine unique number from table and sum the number of time success and failure are there in second column.
|
An awk solution:
Code:
awk -F, '/success/{s[$1]++; a[$1]} /failure/{f[$1]++; a[$1]} END {for ( i in a ) printf "%d,success=%d,failure=%d\n", i, s[i], f[i]}' file |
All times are GMT -5. The time now is 10:32 PM. |