「Fishの基礎 - 条件分岐」の版間の差分

ナビゲーションに移動 検索に移動
44行目: 44行目:
以下の例では、foo.txtファイルが通常のファイルで読み取り可能な場合、<u>foo.txt exists and is readable</u>と表示している。<br>
以下の例では、foo.txtファイルが通常のファイルで読み取り可能な場合、<u>foo.txt exists and is readable</u>と表示している。<br>
  <syntaxhighlight lang="fish">
  <syntaxhighlight lang="fish">
  if [ -f foo.txt ] and [ -r foo.txt ]
  if [ -f foo.txt ]; and [ -r foo.txt ]
     echo "foo.txt exists and is readable"
     echo "foo.txt exists and is readable"
  end
  end
   
   
  # []コマンドではなく、testコマンドを使用する場合
  # []コマンドではなく、testコマンドを使用する場合
  if test -f foo.txt and test -r foo.txt
  if test -f foo.txt; and test -r foo.txt
     echo "foo.txt exists and is readable"
     echo "foo.txt exists and is readable"
  end
  end

案内メニュー