Linux Boot Loader Features of Bash Shell
It is very easy to learn bash shell scripting. There are different Unix shells like bash, ksh, zsh, sh etc. Please make sure that which shell do you want to use while running the script, because syntax of each shell might be different. Before going to develop shell script, your logic or flow of the script should be clear then only you can develop shell script very easily. It is very important to have clear understanding of when or where not to use shell script.
For Fibonacci series shell script, need to know the exact number series. It will be as :
1 1 2 3 5 8 13 21 34 etc.
Please see below is the script to get desired output.
######################Fibonacci.sh###############################
echo "How many numbers do you want of Fibonacci series ?"
read total
x=0
y=1
i=2
echo "Fibonacci Series up to $total terms :: "
echo "$x"
echo "$y"
while [ $i -lt $total ]
do
i=`expr $i + 1 `
z=`expr $x + $y `
echo "$z"
x=$y
y=$z
done
Click to
know more about: Difference of Linux and Unix
|