I decided to take a Unix Introduction class and have never had experience with programming. Everything was fine until recently when the Prof. started shell scripting and he wants us to make a small script to add unlimited numbers from arguments and from standard input.
I admit I am really bad at understanding his teaching, for one. He teaches this class as you had previous experience with programming and when i ask him questions he is very evasive with his answers. My problem is that he didn't have a lecture about flowcharts and i don't understand how to make it work for unlimited numbers introduced.
I was able to make a small script that can add 5 numbers from arg and 5 from input but that is all. he told me to use whiles and fors but i cant seem to grasp the logic so now I am asking you for my help.
I will post here his requirements for the script and also the code for the script that i wrote hoping that somebody can help me.
I appreciate all the help and i will check later with you.
Do not post classroom or homework problems in the main forums. Homework and coursework questions can only be posted in this forum under special homework rules.
Please review the rules, which you agreed to when you registered, if you have not already done so.
More-than-likely, posting homework in the main forums has resulting in a forum infraction. If you did not post homework, please explain the company you work for and the nature of the problem you are working on.
Hi,
I need a help with arithmetic calculations in my script. I have two variables: a=17; b=1712
I want to perform ($a/$b)*100 with two decimals in the result.
I tried with following:
res=$((100*a/b))
res=`echo "scale=2; $a / $b" | bc`
But I am not getting the decimal values.... (4 Replies)
Hello everybody,
I decided to take a Unix Introduction class and have never had experience with programming. Everything was fine until recently when the Prof. started shell scripting and he wants us to make a small script to add unlimited numbers from arguments and from standard input.
I... (8 Replies)
I am begining to learn bourne shell and as a practice I have written a script which when given the purchase price and percentage of discount calculates the savings.
I somehow cannot figure out why my script fails to do arthimatic calculation on real numbers.
Could anyone look at the script... (5 Replies)
Hello,
was just wondering how to compare strings in unix? I mean as in C there is a function strcmp() in string.h, is there any function in unix for that? I tried using
if
and all such variations but didn't succeed. Any help would be appreciated. Thanks in advance :) (9 Replies)
I'm new to this and I need help with writing a script. The following assignment is as follows...
Create a shell script named Project3-8 located in a directory supported by the File System Hierarchy Standard.
The script needs to perform the following pseudocode in the order shown:
-Display... (1 Reply)
I have to complete my assignment and i need help...
These are two simple shell script programs :
1.) Write a shell script to display files in the current directory in the following format :
FileName Size Date Protection Owner
_______ ____ ___ ________ _____
2.) Write a... (1 Reply)
advance happy new year to all,
i am having a script.The purpose of the scripts is as follows.If the current month is march,june,september or december ,inc_flg should be set to '1' otherwise inc_flg should be set to '2'
month= date +"%m"
if || || ||
; then
inc_flg = 1
else
... (6 Replies)