Chinaunix首页 | 论坛 | 博客
  • 博客访问: 1692012
  • 博文数量: 362
  • 博客积分: 10587
  • 博客等级: 上将
  • 技术积分: 4098
  • 用 户 组: 普通用户
  • 注册时间: 2009-09-10 18:15
文章分类

全部博文(362)

文章存档

2014年(1)

2013年(58)

2011年(115)

2010年(112)

2009年(76)

分类:

2010-09-20 15:25:45

scripts 在执行之前,最怕的就是出现问题了!那么我们如何 debug 呢?有没有办法不需要透过直接执行该 scripts 就可以来判断是否有问题呢!?呵呵!当然是有的!我们就直接以 sh 来进行判断吧! 
 
[test @test test]# sh [-nvx] scripts 
-n :不要执行 scripts ,查询 scripts 内的语法,若有错误则予以列出! 
-v :在执行 scripts 之前,先将 scripts 的内容显示在屏幕上; 
-x :将有使用到的 scripts 内容显示在屏幕上,与 -v 稍微不同! 
[test @test test]# sh -n test01-hello.sh 
[test @test test]# sh -v test01-hello.sh 
#!/bin/bash 
# This program will print the "Hello! How are you" in your monitor 
# Date: 2002/06/27 
# User: VBird 
hello="Hello! How are you" 
echo $hello 
Hello! How are you 
[test @test test]# sh -x test01-hello.sh 
+ hello=Hello! How are you 
+ echo 'Hello!' How are you 
Hello! How are you

熟悉 sh 的用法,将可以使您在管理 Linux 的过程中得心应手! 
  

阅读(597) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~