b2科目四模拟试题多少题驾考考爆了怎么补救
b2科目四模拟试题多少题 驾考考爆了怎么补救

shell脚本for循环 鸟哥的linux私房菜(9)

电脑杂谈  发布时间:2018-01-07 20:06:31  来源:网络整理

# 2015/07/17 VBird First release

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:~/bin

export PATH

read -p "Please input a number, I will count for 12...your_input: " nu

s=0

for (( i=1; i<=${nu}; i=i1 ))

do

s=$((${s}${i}))

done

echo "The result of '123...${nu}' is ==> ${s}"

13.6 shell script的追踪与调试

语法

我们就直接以 bash 的相关参数来进行判断

语法:

>sh [-nvx] scripts.sh

选项与参数:

-n :不要执行 script,仅查询语法的问题;

-v :再执行 sccript 前,先将 scripts 的内容输出到屏幕上;

-x :将使用到的 script 内容显示到屏幕上,这是很有用的参数!

范例

范例一:测试 dir_perm.sh 有无语法的问题?

[dmtsai@study ~]$ sh -n dir_perm.sh

# 若语法没有问题,则不会显示任何信息!

范例二:将 show_animal.sh 的执行过程全部列出来~

[dmtsai@study ~]$ sh -x show_animal.sh

PATH=/bin:/sbin:/usr/bin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/root/bin

export PATH

for animal in dog cat elephant

echo 'There are dogs.... '

There are dogs....

for animal in dog cat elephant

echo 'There are cats.... '

There are cats....

for animal in dog cat elephant

echo 'There are elephants.... '

There are elephants....


本文来自电脑杂谈,转载请注明本文网址:
http://www.pc-fly.com/a/jisuanjixue/article-58905-9.html

相关阅读
    发表评论  请自觉遵守互联网相关的政策法规,严禁发布、暴力、反动的言论

    热点图片
    拼命载入中...