Shell 笔记

2009-7-12 10:19:18 by sun

1:保存命令的结果
$(ls -l /) 或者 `ls -l /`
2:判断 [[]] 与 []
[ -z $(ls -l /)] 或者 test
一个目录是否为空: [[ -z $(ls /a)]]||&&echo empty|| echo “not empty”

3:$(()) 算数运算
VAR=1
VAR=$(($VAR+1))
echo $VAR
4:while 循环
The general syntax as follows for bash while loop:

while [ condition ]
do
command1
command2
commandN
done

The condition is evaluated, and if the condition is true, the command1,2…N is executed.
This repeats until the condition becomes false.
The condition can be integer ($i < 5), file test ( -e /tmp/lock ) or string ( $ans != "" )
5: $<

#!/bin/csh
echo -n "Enter your name : "
	set yname = $<

随机文章:

李老爷庙会
李老爷庙会

明天就是光棍节啦
明天就是光棍节啦

网站2011第一季度流量分析
网站2011第一季度流量分析

IBM T42拆机
IBM T42拆机

php支持gd库
php支持gd库

一次做鸡的经历
一次做鸡的经历

发表评论