Keyを確認できるUnixスクリプトファイルはありますか?

Keyを確認できるUnixスクリプトファイルはありますか?

-n、などの文字の全体的な意味を説明する鍵がありますか-d

例:

if [[ -d ${directory_name} ]]; then ...; fi

鍵は何-dで、どこで見つけることができますか?

例:

while [[ -n ${variable_name} ]]; do ...; done

どういう-n意味ですか?

この、、、、、、などをすべて説明するガイドはありますか-n-e-a-d-s-h

私は多くのUnixシェルスクリプトを実行しており、これらのパラメータがループで使用されているか、変数やファイルの場所などのif thenステートメントで使用されているのがわかりました。

上記のスクリプトの各パラメータを説明できる場所を探しています。

答え1

私はシェルのマニュアルページ(例えばman bash)ですべての詳細を見つける必要があると思います。

また、bashたとえばという組み込みコマンドがありますhelp。パラメータにコマンドを発行するだけです。ここにあるコマンドはコマンド(別名)にリダイレクトされるので、[[必要なものを提供します。help [[test[help test

最後に、組み込み関数には通常スタンドアロン関数があり、マン/binページを提供することがよくあります =>man [またはman test

答え2

BASHのTLDPページが欲しい

高級バッシュ:http://www.tldp.org/LDP/abs/html/index.html

初心者の乱交:http://tldp.org/LDP/Bash-Beginners-Guide/html/index.html

あなたが尋ねているものファイルテスト演算子ここで見つけることができます:http://www.tldp.org/LDP/abs/html/fto.html

そしてbash条件式ここで見つけることができます:http://www.gnu.org/software/bash/manual/html_node/Bash-Conditional-Expressions.html

-d  file is a directory
-f  file is a regular file
-e  file exists
-s  file size is not zero
-b  file is a block device
-h  file is a symbolic link
-w  file has write permissions for user executing this bash statement
{there are more}

#!/bin/bash
if [ -e $1 ] && [ -w $1 ]; then
   echo "the file you entered was "$1" and it exists and you have write permission to it"
else
   echo "condition failed for exist and for write permission"
fi

関連情報