[root@localhost wyb]# cat fibo.sh
#!/bin/bash #斐波那契数列 ,,,,,,, echo > file
echo >> file count=$ for i in `seq $count`
do
first=$(tail - file |head -)
two=$(tail - file)
echo $((first+two)) >> file
done
cat file
[root@localhost wyb]# bash fibo.sh [root@localhost wyb]# bash fibo.sh [root@localhost wyb]#
第二种方法,通过间接赋值来来传。用到read -p

[root@localhost wyb]# cat 2fibo.sh
#!/bin/bash #斐波那契数列 ,,,,,,, echo > file
echo >> file #count=$
read -p "Please Input a number:" count
for i in `seq $count`
do
first=$(tail - file |head -)
two=$(tail - file)
echo $((first+two)) >> file
done
cat file
[root@localhost wyb]# bash 2fibo.sh
Please Input a number: [root@localhost wyb]# bash 2fibo.sh
Please Input a number: [root@localhost wyb]# bash 2fibo.sh
Please Input a number: [root@localhost wyb]#
 
05-11 09:42