Count duplicate lines ignoring certain columns

I have this structure:

col1 col2 col3 col4 col5
27	xxx	38	aaa	ttt	
2	xxx	38	aaa	yyy
1	xxx	38	aaa	yyy

I need to collapse duplicate lines ignoring column 1 and add values of duplicate lines (col1) so it will look like this:

col1 col2 col3 col4 col5
27	xxx	38	aaa	ttt	
3	xxx	38	aaa	yyy

I'm using uniq -c -f1 but it doesn't help with the addition of the numbers in the first column:

1 	 col1 col2 col3 col4 col5
1 	 27	xxx	38	aaa	ttt	
2 	 3	xxx	38	aaa	yyy

Could you please help me with this?

Thank you!

Using awk; reading input file twice:

awk '
        NR == 1 {
                print
        }
        NR == FNR && NR > 1 {
                i = $2 FS $3 FS $4 FS $5
                A += $1
                next
        }
        {
                i = $2 FS $3 FS $4 FS $5
                if ( ( i in A ) && !( i in R ) )
                        print A, i
                R
        }
' file file
1 Like

It works! Thank you so much, Yoda! Could you please briefly explain what does it do? I'm trying to learn awk.

Or:

awk 'NR==1{print; next} {v=$1; sub(v,x); C[$0]+=v} END{for(i in C) print C i}' file