這個問題是更多或更少上的變體 https://unix.stackexchange.com/questions/242946/using-awk-to-sum-the-values-of-a-column-based-on-the-values-of-another-column使用AWK總結列的值的基礎上,另一列的值,總和和百分比附加到原始數據
相同的輸入:
smiths|Login|2
olivert|Login|10
denniss|Payroll|100
smiths|Time|200
smiths|Logout|10
我想有以下結果:
smiths|Login|2|212
olivert|Login|10|10
denniss|Payroll|100|100
smiths|Time|200|212
smiths|Logout|10|212
因此,第3列的總和的所有條目與colu相同的圖案應該附加mn 1。
此外,追加另一列用百分比,得到以下結果:
smiths|Login|2|212|0.94
olivert|Login|10|10|100
denniss|Payroll|100|100|100
smiths|Time|200|212|94.34
smiths|Logout|10|212|4.72
偉大的作品,謝謝! – Markus