Sponsored Content
Homework and Emergencies Homework & Coursework Questions Sum of even numbers from 0 to 100 script Post 303031639 by wisecracker on Sunday 3rd of March 2019 06:02:15 AM
Old 03-03-2019
Hi Nastybutler...

Your OP suggests you 'must us[e] a while loop', therefore a for loop is not required at this point.
This is pseudocode, see if you can adapt it.

Code:
shebang needed to call your shell required

assign_a_COUNTer_to_zero
assign_my_SUM_a_starting_point_of_zero

while test[ing] against the 100 limit
do
    do your arithmetic here which uses both SUM and COUNT
    optional, print each line if you want to here to see how it is doing
    increase your COUNTer by your needed amount
done
print your final value here and should equal the last line of you optional listing

EDIT:
And thoroughly read Don's post...

Last edited by wisecracker; 03-03-2019 at 08:10 AM..
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

how to sum numbers in column

Hi, i want to sum all nubers in one column. Example: 12.23 11 23.01 3544.01 I'm trying to do this in awk, but it doesn't work properly. Seems like awk is summing only integers, for example: 12 11 23 3544 It cuts off numbers after dot. I used this command: akw /text/ file.txt |nawk... (1 Reply)
Discussion started by: iahveh
1 Replies

2. Shell Programming and Scripting

sum numbers from stdout

hello im looking for short way to sum numbers from stdout the way i found to do it is to long for me i wander if there is shorter way to do it ok it 2 stage action this will make the list of number in to file sum.txt grep -c include *.c | awk '{l=split($0,a,":");print a;}' > sum.txt this... (1 Reply)
Discussion started by: umen
1 Replies

3. Shell Programming and Scripting

Shell script to find the sum of first n Fibonacci numbers

pls give me the solution for this i need it for my exam pls pls pls Shell script to find the sum of first n Fibonacci numbers (1 Reply)
Discussion started by: Kshitija
1 Replies

4. Homework & Coursework Questions

Help with shell script to find sum of first n numbers of Fibonacci series

Use and complete the template provided. The entire template must be completed. If you don't, your post may be deleted! 1. The problem statement, all variables and given/known data: Shell script to find sum of first n numbers of Fibonacci series 2. Relevant commands, code, scripts,... (0 Replies)
Discussion started by: Kshitija
0 Replies

5. Shell Programming and Scripting

Finding the sum of two numbers

cat *.out |grep "<some text>" | awk '{print $6}' For ex,This will reutrn me 11111 22222 is it possible to add these two numbers in the above given command itself?I can write this to a file and find the sum. But I prefer to this calculation in the above given line itself. Any... (3 Replies)
Discussion started by: prasperl
3 Replies

6. Shell Programming and Scripting

getting the sum of numbers

I basically have a file where I had to do a bunch of greps to get a list of numbers example: a file called numbers.txt 10000 10000 superman 10000 batman 10000 10000 grep '100' * | 10000 10000 10000 10000 10000 (2 Replies)
Discussion started by: zerofire123
2 Replies

7. Shell Programming and Scripting

Sum Numbers from different files

Hi All, I need to print the sum of numbers from different files. Input files: file1.out 10 20 30 file2.out 10 20 30 (5 Replies)
Discussion started by: saint2006
5 Replies

8. Shell Programming and Scripting

Script Shell: Count The sum of numbers in a file

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. (3 Replies)
Discussion started by: chercheur111
3 Replies

9. Shell Programming and Scripting

Shell script count lines and sum numbers from multiple files

I want to count the number of lines, I need this result be a number, and sum the last numeric column, I had done to make this one at time, but I need to make this for a crontab, so, it has to be an script, here is my lines: It counts the number of lines: egrep -i String file_name_201611* |... (5 Replies)
Discussion started by: Elly
5 Replies

10. UNIX for Beginners Questions & Answers

Sum even numbers from 1 to 100

I need help with this assignment. I'm very new to using UNIX/LINUX, and my only previous experience with programing anything is using python. We are writing scripts using vim, and this one I'm stumped on. "Write a shell script that finds and display the sum of even positive integers from 0 to... (5 Replies)
Discussion started by: Nastybutler
5 Replies
dahdi_test(8)						      System Manager's Manual						     dahdi_test(8)

NAME
dahdi_test -- Test if the DAHDI timer provides timely response SYNOPSIS
dahdi_test [ -v ] DESCRIPTION
dahdi_test dahdi_test runs a timing test in a loop and prints the result of each loop. The test is as follows: It reads 8192 bytes from the DAHDI timer device (/dev/dahdi/pseudo). This should take exactly 8000 ms . It uses calls to gettimeofday(2) before and after that read to check that indeed exactly 8000ms have passed. Values of 100% and 99.99% Are normally considered a definite pass. Values of 99.98% and 99.97% are probably OK as well. OPTIONS
-v Be more verbose: print one line per test. -c count Run for count times instead of running forever. FILES
/dev/dahdi/pseudo The device file used to access the DAHDI timer. SEE ALSO
dahdi_tool(8), dahdi_cfg(8), asterisk(8). gettimeofday(2) AUTHOR
This manual page was written by Tzafrir Cohen <tzafrir.cohen@xorcom.com> Permission is granted to copy, distribute and/or modify this docu- ment under the terms of the GNU General Public License, Version 2 any later version published by the Free Software Foundation. 2005-06-25 dahdi_test(8)
All times are GMT -4. The time now is 09:22 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy