Hi all;
Here is my file:
V1.3=4
V1.4=5
V1.1=3
V1.2=6
V1.3=6
Please, can you help me to write a script shell that counts the sum of values in my file (4+5+3+6+6) ?
Thank you so much for help.
Kind regards.
Hi all;
Here is my file:
V1.3=4
V1.4=5
V1.1=3
V1.2=6
V1.3=6
Please, can you help me to write a script shell that counts the sum of values in my file (4+5+3+6+6) ?
Thank you so much for help.
Kind regards.
Hello chercheur111,
Could you please try following and let me know if this helps you.
awk -F"=" '{SUM=SUM?SUM+$NF:$NF} END{print "SUM = "SUM}' Input_file
Output will be as follows.
SUM = 24
Thanks,
R. Singh
Thank you so much for help
Kind regards.
This could be simplified a little bit to:
awk -F"=" '{SUM+=$NF} END{print "SUM = "SUM}' Input_file
If you want to try this on a Solaris/SunOS system, change awk
to /usr/xpg4/bin/awk
or nawk
.