# UNIX or Linux code

**URL:** <https://forums.speedlife.net/t/unix-or-linux-code/41951>\
**Category:** NYSpeed Off Topic\
**Created:** [January 16, 2008, 3:45pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951 "2008-01-16T15:45:31Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![eric416](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@eric416](https://forums.speedlife.net/u/eric416)\
**Post date:** [January 16, 2008, 3:45pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/1 "2008-01-16T15:45:31Z")

</div>

Anyone know unix or linux code and can help me write 3 simple programs?

---

<div class="post-metadata">

**Author:** ![LZ1](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@LZ1](https://forums.speedlife.net/u/LZ1)\
**Post date:** [January 16, 2008, 3:47pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/2 "2008-01-16T15:47:23Z")

</div>

shell scripts?

c?

I g0tz dem sweet c0dez

---

<div class="post-metadata">

**Author:** ![LZ1](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@LZ1](https://forums.speedlife.net/u/LZ1)\
**Post date:** [January 16, 2008, 3:49pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/3 "2008-01-16T15:49:37Z")

</div>

#include\<stdio.h\>

int main()  
{  
printf("Hello World  
");  
return 0;  
}

---

<div class="post-metadata">

**Author:** ![eric416](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@eric416](https://forums.speedlife.net/u/eric416)\
**Post date:** [January 16, 2008, 3:53pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/4 "2008-01-16T15:53:23Z")

</div>

yea shell scripts, i’m taking a unix class during the winter term and its impossible to learn this code in such a short time. Its a whole semesters worth in 2 weeks.  
this is what I have to do:

1. Write a program that will allow a user to input as many numbers as the user wants (999 as the choice that ends the user input). The program will then respond:

Highest Number: Answer  
Lowest Number: Answer  
Sum of the numbers: Answer  
Average of the numbers: Answer

1. Create a Number guessing game. Have the computer pick a number from 0-60.  
Then allow the user to guess at the number until the user gets it right. (Hint you can use the seconds from the clock to get the number to guess). Please include the following:

a) Keep a counter of how many guesses were made, and then tell the user how many guesses it took.

b) As the user guesses, tell the user whether the guess is too high or too low.

1. Write a program that will allow a user to type in a number, then the number will either count up to the number provided by the user or count down from that number. In addition, create a menu that will let the user choose which counter they wish to use. In both cases that counter will either count down to 0, or start counting from 0.

---

<div class="post-metadata">

**Author:** ![boardjnky4](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@boardjnky4](https://forums.speedlife.net/u/boardjnky4)\
**Post date:** [January 16, 2008, 4:13pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/5 "2008-01-16T16:13:36Z")

</div>

at first i was like, “oh my maybe its the same kinda class my buddy eric is taking” then i saw the username. lol. If I have some time tomorrow I will try to help you

Just so you guys know, the shell scripts must be written for sh/ksh

---

<div class="post-metadata">

**Author:** ![LZ1](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@LZ1](https://forums.speedlife.net/u/LZ1)\
**Post date:** [January 16, 2008, 4:14pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/6 "2008-01-16T16:14:33Z")

</div>

I am going out to dinner I will take a look at this when I get home.

---

<div class="post-metadata">

**Author:** ![Matt\_Danger](https://yyz2.discourse-cdn.com/flex034/user_avatar/forums.speedlife.net/matt_danger/32/4981_2.png) [@Matt\_Danger](https://forums.speedlife.net/u/Matt_Danger)\
**Post date:** [January 16, 2008, 4:17pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/7 "2008-01-16T16:17:18Z")

</div>

“man ksh” should give you a good starting point.

---

<div class="post-metadata">

**Author:** ![eric416](https://avatars.discourse-cdn.com/v4/letter/e/e56c9b/32.png) [@eric416](https://forums.speedlife.net/u/eric416)\
**Post date:** [January 16, 2008, 4:29pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/8 "2008-01-16T16:29:30Z")

</div>

thanks guys

---

<div class="post-metadata">

**Author:** ![boardjnky4](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@boardjnky4](https://forums.speedlife.net/u/boardjnky4)\
**Post date:** [January 16, 2008, 4:31pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/9 "2008-01-16T16:31:09Z")

</div>

im working on the first one now, so don’t do that one

---

<div class="post-metadata">

**Author:** ![Matt\_Danger](https://yyz2.discourse-cdn.com/flex034/user_avatar/forums.speedlife.net/matt_danger/32/4981_2.png) [@Matt\_Danger](https://forums.speedlife.net/u/Matt_Danger)\
**Post date:** [January 16, 2008, 4:42pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/10 "2008-01-16T16:42:50Z")

</div>

Haha, almost done with the first.

Shell scripts are fun.

---

<div class="post-metadata">

**Author:** ![boardjnky4](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@boardjnky4](https://forums.speedlife.net/u/boardjnky4)\
**Post date:** [January 16, 2008, 4:44pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/11 "2008-01-16T16:44:32Z")

</div>

number 1 is complete and sent off

---

<div class="post-metadata">

**Author:** ![boardjnky4](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@boardjnky4](https://forums.speedlife.net/u/boardjnky4)\
**Post date:** [January 16, 2008, 4:47pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/12 "2008-01-16T16:47:29Z")

</div>

> [@Matt Danger](#):
>
> Haha, almost done with the first.
> 
> Shell scripts are fun.

its already done

---

<div class="post-metadata">

**Author:** ![Matt\_Danger](https://yyz2.discourse-cdn.com/flex034/user_avatar/forums.speedlife.net/matt_danger/32/4981_2.png) [@Matt\_Danger](https://forums.speedlife.net/u/Matt_Danger)\
**Post date:** [January 16, 2008, 4:49pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/13 "2008-01-16T16:49:50Z")

</div>

Damn you, just finished

---

<div class="post-metadata">

**Author:** ![Matt\_Danger](https://yyz2.discourse-cdn.com/flex034/user_avatar/forums.speedlife.net/matt_danger/32/4981_2.png) [@Matt\_Danger](https://forums.speedlife.net/u/Matt_Danger)\
**Post date:** [January 16, 2008, 4:51pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/14 "2008-01-16T16:51:36Z")

</div>

I’m not going to do these for him, I don’t think that would help him in the long run. I was going to help him when he hit a wall.

---

<div class="post-metadata">

**Author:** ![boardjnky4](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@boardjnky4](https://forums.speedlife.net/u/boardjnky4)\
**Post date:** [January 16, 2008, 4:53pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/15 "2008-01-16T16:53:12Z")

</div>

he goes to school for construction management engineering, i doubt he will ever look back at this shit

---

<div class="post-metadata">

**Author:** ![Matt\_Danger](https://yyz2.discourse-cdn.com/flex034/user_avatar/forums.speedlife.net/matt_danger/32/4981_2.png) [@Matt\_Danger](https://forums.speedlife.net/u/Matt_Danger)\
**Post date:** [January 16, 2008, 4:56pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/16 "2008-01-16T16:56:59Z")

</div>

Ah, how come he has to take this course then?

I’m gonna jump to 3 😉

---

<div class="post-metadata">

**Author:** ![Matt\_Danger](https://yyz2.discourse-cdn.com/flex034/user_avatar/forums.speedlife.net/matt_danger/32/4981_2.png) [@Matt\_Danger](https://forums.speedlife.net/u/Matt_Danger)\
**Post date:** [January 16, 2008, 5:10pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/17 "2008-01-16T17:10:55Z")

</div>

Sent

---

<div class="post-metadata">

**Author:** ![LZ1](https://avatars.discourse-cdn.com/v4/letter/l/7ab992/32.png) [@LZ1](https://forums.speedlife.net/u/LZ1)\
**Post date:** [January 16, 2008, 9:03pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/18 "2008-01-16T21:03:42Z")

</div>

Post up the code

---

<div class="post-metadata">

**Author:** ![ILCisDEAD](https://avatars.discourse-cdn.com/v4/letter/i/a87d85/32.png) [@ILCisDEAD](https://forums.speedlife.net/u/ILCisDEAD)\
**Post date:** [January 16, 2008, 9:10pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/19 "2008-01-16T21:10:01Z")

</div>

lol I could do it in C++ and Perl… not shell script though ☹

---

<div class="post-metadata">

**Author:** ![boardjnky4](https://avatars.discourse-cdn.com/v4/letter/b/96bed5/32.png) [@boardjnky4](https://forums.speedlife.net/u/boardjnky4)\
**Post date:** [January 16, 2008, 9:32pm UTC](https://forums.speedlife.net/t/unix-or-linux-code/41951/20 "2008-01-16T21:32:37Z")

</div>

heres the code for the first problem in case anyone wanted to see how its done

```auto
#!/bin/ksh

current_high=$1
current_low=$1
sum=0
for arg;do
sum=$(($sum+$arg))
if [$current_high -lt $arg] ; then
   current_high=$arg
fi

if [$arg -lt $current_low] ; then
   current_low=$arg
fi

done
avrg=$(($sum/$#))
print "Highest Number: "$current_high
print "Lowest Number: "$current_low
print "Sum of the numbers: "$sum
print "Average of the numbers: "$avrg

```

[Next page](https://forums.speedlife.net/t/unix-or-linux-code/41951.md?page=2)
