shell编程中的条件判断

: 表示为真

条件
if-then
case

if-then
单条件
if command
then
commands
fi
当command返回码为0时 条件成立

在if,elif中要注意
中括号 [] 里面左右两边必须要有空格
== 两边也必须有空格 否者也不对

if.sh
#! /bin/bash
if :
then
    echo true
fi
[root@centos1 sh]# sh -x if.sh 
+ '[' 1 == 1 ']'
+ echo true
true
View Code

相关文章:

  • 2021-11-18
  • 2022-12-23
  • 2021-11-13
  • 2022-12-23
  • 2022-01-03
  • 2022-12-23
  • 2022-12-23
  • 2021-09-23
猜你喜欢
  • 2021-07-01
  • 2021-11-30
  • 2022-12-23
  • 2021-06-11
  • 2021-11-05
  • 2022-01-16
相关资源
相似解决方案