Linux if文 論理和のサンプル

環境
AlmaLinux 9.2

構文
if [左の条件式] || [右の条件式]
左の式または右の式のどちらかがtrueの場合、trueになります。

使用例

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
#!/bin/bash
x=1
if [ $x -eq 0 ] || [ $x -lt 10 ]; then
echo "true"
fi
#!/bin/bash x=1 if [ $x -eq 0 ] || [ $x -lt 10 ]; then echo "true" fi
#!/bin/bash
x=1

if [ $x -eq 0 ] || [ $x -lt 10 ]; then
      echo "true" 
fi

結果
true

shellscript

Posted by arkgame