Script to Count the Numeric Values and get the Total


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Script to Count the Numeric Values and get the Total
# 1  
Old 02-19-2013
Script to Count the Numeric Values and get the Total

Can anyone help me in this?

Here is the Secenario.

I need to count the Numerical vaues from the below output

Item processed: 1401
Item processed: 2839
Item processed: 1261
Item processed: 2584
Item processed: 2
Item processed: 988
Item processed: 1
Item processed: 2119


Please give me the script to count all these values and To give a single Total value...


Sorry for English..
# 2  
Old 02-19-2013
Please use code tags for code and data sample.
And before posting any question first try to search in the forums Smilie
Try
Code:
awk '{a+=$NF}END{print a}' file

This User Gave Thanks to pamu For This Post:
# 3  
Old 02-19-2013
Thanks... I am a newbie....

---------- Post updated at 06:42 PM ---------- Previous update was at 06:20 PM ----------

Quote:
Originally Posted by pamu
Please use code tags for code and data sample.
And before posting any question first try to search in the forums Smilie
Try
Code:
awk '{a+=$NF}END{print a}' file


Thank you very much, It worked like a charm... But It shows only a Total value. I need the Output like

Code:
Overall Total Proccessed = 'Total value'

Thanks in advance.
# 4  
Old 02-19-2013
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Finding total distinct count from multiple csv files through UNIX script

Hi All , I have multiple pipe delimited csv files are present in a directory.I need to find out distinct count on a column on those files and need the total distinct count on all files. We can't merge all the files here as file size are huge in millions.I have tried in below way for each... (9 Replies)
Discussion started by: STCET22
9 Replies

2. UNIX for Dummies Questions & Answers

In ls -l remove total count

Hi All, When i give ls -ltr i get 'total 10' like this along with files long listing. is there any option in ls command to remove this line or do we need use head -1 command only. $ls -ltr total 45 -rw-r--r-- 1 abc g1 0 Jul 17 07:20 0 -rw-r--r-- 1 abc g1 744 May 9 12:10 a -rw-r--r--... (1 Reply)
Discussion started by: HemaV
1 Replies

3. AIX

Pattern count for numeric values in aix

Hi All , I have a small code that checks pattern of digits entered in unix mode . $ echo 201202 | wc -c 7 /* output*/ When i run same command in AIX 5.1 , i am getting output with some initial blanks $ echo 201202 | wc -c 7 ... (4 Replies)
Discussion started by: Perlbaby
4 Replies

4. Shell Programming and Scripting

Total Count using AWK

Hi Everybody, I have the following example file... 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1 199|TST-GURGAON|GURGAON|1... (8 Replies)
Discussion started by: sraj142
8 Replies

5. Shell Programming and Scripting

Use AWK to check for numeric values? (BASH script)

Hi, I'm quite new to scripting, but know a few AWK statements. I have the following line in my script: hostname=`echo $file | awk 'BEGIN{FS=OFS="."}{$NF=""; NF--; print}'` I use this in my script to rename files, which are similar to this: name.mvkf.mkvfm.mkfvm.1 To the... (4 Replies)
Discussion started by: TauntaunHerder
4 Replies

6. Shell Programming and Scripting

Help with script to read lines from file and count values

Hi, I need some help with a script I'm trying to write. I have a log file containing references to a number of different webservices. I wish to write a script that will list the webservices with a count as to how many times they appear in the log. An example of the log file content: ... (2 Replies)
Discussion started by: gman2010
2 Replies

7. Shell Programming and Scripting

perl script on how to count the total number of lines of all the files under a directory

how to count the total number of lines of all the files under a directory using perl script.. I mean if I have 10 files under a directory then I want to count the total number of lines of all the 10 files contain. Please help me in writing a perl script on this. (5 Replies)
Discussion started by: adityam
5 Replies

8. Shell Programming and Scripting

Count the alpha numeric

Hi all. This is one of my interview question. input : apple output : a - 1 p - 2 l - 1 e - 1 i written the code like this echo "apple" | fold -w1 | sort | uniq -c | awk '{print $2 "-->" $1}' is any other way to do ? (5 Replies)
Discussion started by: itkamaraj
5 Replies

9. Shell Programming and Scripting

Need help in shell script to trim numeric values

Hello I am currently working on a shell script which actually needs to pull some file from a server , The filenames will have the extension with date/time stamp , i need to trim that and name it to proper format Example : xyz_20091108_22142365.gzip i need to remove the... (5 Replies)
Discussion started by: ranga27
5 Replies
Login or Register to Ask a Question