Quizzes & Puzzles38 mins ago
Shell Script (Unix) Help Please.
5 Answers
I am trying to write a script whereby i ask a user to input a number and then output a table of multiplication for the number given. So if "6" was entered, it would print out:
1x6=6
2x6=12
3x6=18
4x6=24
(up to 10 x the number input).
I've created other shell scripts but i just cant get my head around this.
I've got so far:
#!bin/ksh
echo "Enter a number"
read number
Thats it, im finding this really difficult lol. I dont know if any let, read, if, then or else, case statements needed. Any help please?
tnx
1x6=6
2x6=12
3x6=18
4x6=24
(up to 10 x the number input).
I've created other shell scripts but i just cant get my head around this.
I've got so far:
#!bin/ksh
echo "Enter a number"
read number
Thats it, im finding this really difficult lol. I dont know if any let, read, if, then or else, case statements needed. Any help please?
tnx
Answers
Best Answer
No best answer has yet been selected by xAsh. Once a best answer has been selected, it will be shown here.
For more on marking an answer as the "Best Answer", please visit our FAQ.This will do it, but lol I haven't done any shell scripting for quite a while !
#!/bin/ksh
echo "Enter number: "
read number
let x=1
while [[ $x -lt 11 ]]
do
let mult=number*x
echo $x "times" $number " = " $mult
let x=x+1
done
There are other ways (of course being Unix)
for i in 1 2 3 4 5 6 7 8 9 10
do
echo $i
done
The language I gave the previous answer in is one called M (MUMPS). It is absolutely brilliant and I use it all the time (on a Solaris platform) in preference to shell or perl for all general purpose data manipulation.
#!/bin/ksh
echo "Enter number: "
read number
let x=1
while [[ $x -lt 11 ]]
do
let mult=number*x
echo $x "times" $number " = " $mult
let x=x+1
done
There are other ways (of course being Unix)
for i in 1 2 3 4 5 6 7 8 9 10
do
echo $i
done
The language I gave the previous answer in is one called M (MUMPS). It is absolutely brilliant and I use it all the time (on a Solaris platform) in preference to shell or perl for all general purpose data manipulation.
Related Questions
Sorry, we can't find any related questions. Try using the search bar at the top of the page to search for some keywords, or choose a topic and submit your own question.