📢 Webサイト閉鎖と移転のお知らせ
このWebサイトは2026年9月に閉鎖いたします。
新しい記事は移転先で追加しております。(旧サイトでは記事を追加しておりません)
| (同じ利用者による、間の1版が非表示) | |||
| 1行目: | 1行目: | ||
== 概要 == | == 概要 == | ||
if文とは、条件付きコマンドを実行するためのシンタックスである。<br> | |||
<br><br> | <br><br> | ||
| 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 | ||