Sponsored Content
Full Discussion: help with add
Top Forums Shell Programming and Scripting help with add Post 302269407 by uwork72 on Wednesday 17th of December 2008 02:29:06 PM
Old 12-17-2008
help with add

Code:
$ cat file
x A 10 20 30
x B 5 10 12
x C 10 4 5
x D 10 3 6
x K 10 23 4
x M 5 7 0

Req o/p:

Code:
x A 15 30 42
x C 20 7 11
x K 15 30 4

Basically I want to add up 2 rows values as above.


I can sum the whole rows

Code:
$ awk '
{ for (i=3;i<=NF;++i) sum[i]+=$i; j=NF}
END {for (i=3;i<=j;++i) printf "%s%s",OFS,sum[i]}' file

 50 67 57

Please help to add two rows values as I mentioned in my req o/p above, thanks.
 

We Also Found This Discussion For You

1. Shell Programming and Scripting

How to add add some files together and then paste

How can you efficiently add pairs of files together and then paste those pairs, I have a climate computer at work which spits out temperatures and stuff out twice a day, one for the day-data and one for the night (basically). Every week I want to make a nice overview The text files are... (1 Reply)
Discussion started by: uwgandalf
1 Replies
GRUB-RENDER-LABEL(1)                                               User Commands                                              GRUB-RENDER-LABEL(1)

NAME
grub-render-label - generate a .disk_label for Apple Macs. SYNOPSIS
grub-render-label [OPTION...] [OPTIONS] DESCRIPTION
Render Apple .disk_label. -b, --bgcolor=COLOR use COLOR for background -c, --color=COLOR use COLOR for text -f, --font=FILE use FILE as font (PF2). -i, --input=FILE read text from FILE. -o, --output=FILE set output filename. Default is STDOUT -t, --text=STRING set the label to render -v, --verbose print verbose messages. -?, --help give this help list --usage give a short usage message -V, --version print program version Mandatory or optional arguments to long options are also mandatory or optional for any corresponding short options. REPORTING BUGS
Report bugs to <bug-grub@gnu.org>. SEE ALSO
The full documentation for grub-render-label is maintained as a Texinfo manual. If the info and grub-render-label programs are properly installed at your site, the command info grub-render-label should give you access to the complete manual. grub-render-label (GRUB) 2.02-2ubuntu8.3 July 2018 GRUB-RENDER-LABEL(1)
All times are GMT -4. The time now is 07:46 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy