help writing script file


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers help writing script file
# 8  
Old 03-09-2004
Do you know what command I will need to use to find Average. I know that if I have 10 numbers and I add them together then devide the total with 10 I will get the average but I'm not sure how to put it down on a script. Can someone help with this.

Thanks
# 9  
Old 03-09-2004
when doing math in a script do it just like you would read it.

1) read in all the numbers.
2) add all the number
3) divide all the numbers.

problems of this nature are usually in the into to scripting/programming courses offered at various colleges and tecnical schools.
# 10  
Old 03-09-2004
Thanks,

Can't afford college or training right now. I'm trying to learn UNIX on my own, and it's not as easy as I thought. It took me over a week to just figure out the script I did above. I'm currently a windows network administrator and want to switch to UNIX or Linux. I'm not used to working without an interface, but I find Unix very interesting. I HAVE TO LEARN UNIX NO MATTER WHAT. I find it more interesting than Windows since I have to work my brain just to figure problems out. In windows everything was easy so it's nice to work on something challenging for a change.
# 11  
Old 03-09-2004
I'm not understanding how to find the average. Don't laugh but this is what I got and clearly it doesn't work. Does anyone know how to fix this.

ksh-2.04$ cat Average
echo "To Find the Average of 3 Numbers Please Enter 3 Numbers Below: "
read num1 num2 num3
if [ $num1 + num2 + num3=total ]
then
expr total / 3
fi
exit
Smilie Smilie Smilie
# 12  
Old 03-09-2004
Well then lets hope you paid attention during all those math word problems. Smilie

Run your windows apps from the command line, most of them have command line syntax. Use the run line, command, or an explorer bar to get yourself way from the point and click way of life.

Also, use the search function for this site. There are enough links to keep you reading for moons.

I hardly ever have to post a question because I can usally find it somewhere on this site, plus by using the search function first you won't be chastied at beginning of your post for not searching. Smilie
# 13  
Old 03-09-2004
in ksh you can do stuff like:
((total=num1+num2+num3))
echo $total

In a ((...)) type statement you do not need the $ in front of the variable name.
# 14  
Old 03-09-2004
Awsome,

Thanks everyone, I appreciate all the help.

Lanboy_2005 Smilie
 
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Help Writing File Restore Script

Hi all, I have been tasked with creating a script that sends a file into a created "recycling" directory and another script that restores a "deleted" file. I have already created the removal script but am stuck on the restoring part. I need to restore the file to its original location by... (0 Replies)
Discussion started by: bashbeginner
0 Replies

2. UNIX for Dummies Questions & Answers

Writing a script that will take the first line from each file and store it in an output file

Hi, I have 1000 files names data1.txt through data1000.txt inside a folder. I want to write a script that will take each first line from the files and write them as output into a new file. How do I go about doing that? Thanks! (2 Replies)
Discussion started by: evelibertine
2 Replies

3. Shell Programming and Scripting

writing the main script file

Hi, I am new to shell scripting,and i was planning to write a script that will move files which have a datetime >= currentdate-N from a source to destination folder. All configuration should be done through a properties files. Here the value of N should be taken as 10 days(modification... (6 Replies)
Discussion started by: rahul125
6 Replies

4. Shell Programming and Scripting

Need help in writing a script to edit a file

Hi all, I need help in writing a script to edit a file Here is the sample of my file abc xxx 123 456 789 045 def yyy 987 678 098 cdf zzz 435 543 jhg vvv 987 765 (2 Replies)
Discussion started by: leo.maveriick
2 Replies

5. Shell Programming and Scripting

Help with writing shell script file

I am trying to prompt the user using tput command to read the information ( 5 last names, first names and grades) from the keyboard. Save the data in a file called student.txt. Sort the file by last name and display it on the screen My pseudocode is as follow: Pseudocode: Initialize... (1 Reply)
Discussion started by: jestaton
1 Replies

6. UNIX for Dummies Questions & Answers

Help writing a script to find a file

I just started learning about Unix and I cant figure out what im doing wrong. I'm trying to write a script that will ask for the file name and tell what type it is. This is what i have so far. http://i63.photobucket.com/albums/h123/wacand/untitled.jpg (2 Replies)
Discussion started by: wacand
2 Replies

7. UNIX for Dummies Questions & Answers

HELP! writing shell script with c++ file

how would i write a shell script to count number of one-line comments in a c++ file. please help with coding thank you. (1 Reply)
Discussion started by: deadleg
1 Replies

8. Shell Programming and Scripting

script for writing to a file

Hi, Can some some give ideas/help how to write to a file. i need to create a calender from the inputs given on command line i.e frm date,todate & -i is interval is given to write to a file. -i is 1 then a calender is daily , if -i =2 then calender is alternate day e.g $1 ... (0 Replies)
Discussion started by: innocent
0 Replies

9. Shell Programming and Scripting

writing script file for database

how to disable a constraint type of a field (present in diffrent tables) in the database unix a unix script file.. (3 Replies)
Discussion started by: shaksing
3 Replies

10. Shell Programming and Scripting

Writing to a file within a script

Hi, At the moment i have a script where it asks the user if they want to create a file and what to put in the file. The problem is when the script is run the user inputs the information, though when they are finished typing what they want to be in the file there is no way for the program to know... (3 Replies)
Discussion started by: Jaken
3 Replies
Login or Register to Ask a Question