Hello everyone
I am a beginner in Shell scripting. Need your help to achieve desired result.
I have a file (sample format below)
001g8aX0007jxLz xxxxxxxxxxxxxxx 9213974926411 CO-COMM-133 CO-L001-DLY 7769995578239 44938 1 1
001g8aX0007jw8C xxxxxxxxxxxxxxx 9213974926411 CO-COMM-108 CO-L001-DLY 7769995578239 44199 1 1
001g8aX0001n69f xxxxxxxxxxxxxxx 9213974927136 CO-COMM-132 CO-L001-DLY 7769995583435 44273 2 2
001g8aX0000Pqsp xxxxxxxxxxxxxxx 9213974929242 CO-COMM-114 CO-L001-DLY 7769995598366 44901 2 2
001g8aX00023bjx xxxxxxxxxxxxxxx 9213974929991 ED-COMM-111 CO-L001-DLY 7769995602139 42943 2 2
001g8aX00023hCn xxxxxxxxxxxxxxx 9213974929991 CO-COMM-102 CO-L001-DLY 7769995602139 43012 2 2
Just imaging , i have 4th column '9213974926411' as an envelope and column 8 as page numbers in it. I need to find out total number of pages in one envelope and add the sum in each row as a last column. So the output will be like
001g8aX0007jxLz xxxxxxxxxxxxxxx 9213974926411 CO-COMM-133 CO-L001-DLY 7769995578239 44938 1 1 2
001g8aX0007jw8C xxxxxxxxxxxxxxx 9213974926411 CO-COMM-108 CO-L001-DLY 7769995578239 44199 1 1 2
001g8aX0001n69f xxxxxxxxxxxxxxx 9213974927136 CO-COMM-132 CO-L001-DLY 7769995583435 44273 2 2 2
001g8aX0000Pqsp xxxxxxxxxxxxxxx 9213974929242 CO-COMM-114 CO-L001-DLY 7769995598366 44901 2 2 2
001g8aX00023bjx xxxxxxxxxxxxxxx 9213974929991 ED-COMM-111 CO-L001-DLY 7769995602139 42943 2 2 4
001g8aX00023hCn xxxxxxxxxxxxxxx 9213974929991 CO-COMM-102 CO-L001-DLY 7769995602139 43012 2 2 4
Thanks for help in advance !!