在linux的bash环境下 执行如下脚本do.sh while (true) do PID="`ps -ef | grep aaa|grep -v 'grep' | awk '{print $2}'`" if $PID > 0Sample Text then sleep 300 else date >>do.log echo aaa >>do.log fi done 报错如下: ./do.sh: line 4: 21474: command not found 将if 后加了圆括号 、把>换成 -gt 都试了,仍然报错,搞不懂了,指点一下吧,谢了。
by polosky - Shell - 2006-04-17 18:14:01 阅读(8503) 回复(10)
#!/bin/bash echo "Hit a key, then hit return." read Keypress case "$Keypress" in [a-z] ) echo "Lowercase letter";; [A-Z] ) echo "Uppercase letter";; [0-9] ) echo "Digit";; * ) echo "Punctuation, whitespace, or other";; esac exit 0 为什么输入大写字母也显示lowercase letter呢? case有什么值得注意的地方么? btw:linux 7.3 bash.谢谢
在终端输入 ps -A 假如输出如下一些行 8117 ? 00:00:00 sshd 8118 pts/4 00:00:00 bash 8182 ? 00:00:00 sshd 8184 ? 00:00:00 sshd 8185 pts/5 00:00:00 bash 8751 ? 00:00:00 sshd 8753 ? 00:00:00 sshd 8754 pts/6 00:00:00 bash 12076 ? 00:00:00 sshd 12078 ? 00:00:00 sshd 12079 pts/0 00:00:00 bash 13401 pts/4 00:00:04 vim 13527 pts/0 00...
这个问题我在设定PS1的时候问过了: typeset -RZ2 _x1 _x2 _x3 let SECONDS=$(date '+3600*%H+60*%M+%S') _s='(_x1=(SECONDS/3600)%24)==(_x2=(SECONDS/60)%60)==(_x3=SECONDS%60)' TIME='"${_d[_s]}$_x1:$_x2:$_x3"' export PS1=${TIME} 那两句话,尤其是后面一句怎么理解? :em14: :em13:
不知道shell 脚本能否写成类似C里面的goto功能啊 a: # shell script a ........................ if [ ...... ]; then goto a fi # shell script b 请问上面的可行么?谢谢
出错信息: [root@linux logfile]# ./logfile.sh ./logfile.sh: line 151: declare: 08: value too great for base (error token is "08") ./logfile.sh: line 152: [: : integer expression expected 出错语句的地方: declare -i datenu=`date +%H` if [ "$datenu" -le "6" ]; then date --date='1 day ago' +%b' '%e > "$basedir/dattime" else ...
变量str 储存字符串 "RX bytes:9531887 (9.0 MB) TX bytes:1894191 (1.8 MB)" 怎么把 9531887 和1894191 这两个数字取出来分别放到rx 和 tx 变量中?
在一个安装脚本中有个if语句判断是否已装apachestl if [ -e `locate apachectl | grep '/apachectl$'` -a `locate apachectl | grep '/apachectl$'` ] 有了-a前面的判断 , -a 后面那个判断起什么作用呢?