I have a file with 106 entries on it most look like this:
1 25 34 36 42
I want to be able to number each line (this is easy awk 'NF{$0=++a " :" $0};{print}') but I'd like to add the sum of all numbers at the end so eg the entry would look like (normally awk '{s=0; for (i=1; i<=NF; i++) s=s+$i; print s}')
1: 1 25 34 36 42 138
2: 1 2 3 4 5 15
awk '{s=0; for (i=1; i<=NF; i++) s=s+$i; print s};{s=0; for (i=1; i<=NF; i++) s=s+$i; print s}' didn't seem to work
perl -e 'print $i=pack(c5,(40*2),sqrt(7600),(unpack(c,Q)-3+1+3+3-7),oct(104),10,oct(101));'
1 25 34 36 42
I want to be able to number each line (this is easy awk 'NF{$0=++a " :" $0};{print}') but I'd like to add the sum of all numbers at the end so eg the entry would look like (normally awk '{s=0; for (i=1; i<=NF; i++) s=s+$i; print s}')
1: 1 25 34 36 42 138
2: 1 2 3 4 5 15
awk '{s=0; for (i=1; i<=NF; i++) s=s+$i; print s};{s=0; for (i=1; i<=NF; i++) s=s+$i; print s}' didn't seem to work
perl -e 'print $i=pack(c5,(40*2),sqrt(7600),(unpack(c,Q)-3+1+3+3-7),oct(104),10,oct(101));'