标签:shell各类脚本
#批量修改当前目录下的文件扩展名,将.doc改为.txt
1. [root@svr5 rendir]# vim ../renfilex.sh
2. #!/bin/bash
3. for FILE in "$1"
4. do
5. mv $FILE ${FILE%$1}"$2"
6. done
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
编写sumx.sh脚本,从键盘读入一个正整数x,求从1到x的和
1. [root@svr5 ~]# vim sumx.sh
2. #!/bin/bash
3. read -p "请输入一个正整数:" x
4. x=${x:-1}
5. i=1; SUM=0
6. while [ $i -le $x ]
7. do
8. let SUM+=i
9. let i++
10. done
11. echo "从1到$x的总和是:$SUM"
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
99乘法表
1 #!/bin/bash
2 for((i=1;i<=9;i++))
3 do
4 for ((j=1;j<=9;j++))
5 do
6 echo -ne "$i*$j=$((i*j))\t"
7 done
8 echo
9 done
标签:shell各类脚本
原文地址:http://liangzai818.blog.51cto.com/10003446/1763491