bash和csh的不同
bash:
使用变量 例:a=1
for循环 for ((;;))或者for i in $(ls /root)
do
command
done
while 循环 while [ coniton ];
do
command
done
if 判断语句 if [ variable -eq/-lt/ge number ] ;then
command
if 判断数字是否相等,小于,大于
if [ variable ==/!= 'stirng' ] ;then
command
if 判断字符串是否相等,不等于
多个条件:-a 表示 ’和‘
-o 表示 ‘或’
在脚本中 变量自增 :let var=var+1 或则 var=$(($var+1))
csh:
设置变量 set a=1
if 判断语句 if ( variable ==/>/< number ) then
command
endif 使用大于、小于号来判断数字是否相等
while循环语句 while ( conditon = num )
command
end
多个条件:&& 表示 ’和‘
|| 表示 ‘或’
在脚本中 变量自增 : @ var++ 或则 @ var=var+1
其他冷知识:
set -e 只能在bash中使用 ,csh中是不能使用的,因为是用set设置变量。 而set -e能够在脚本中执行一条语句返回码不为0时,直接退出脚本。而 查看返回码 则使用echo $?
浙公网安备 33010602011771号