Is there a key that explains theese letters such as -n, -d, etc all mean ?


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

What is the -d or where do I find a key?


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

what is the -n mean??

Is there a guide that explains what all of these -n, -e, -a, -d, -s, -h, etc?

I do a lot of Unix shell scripting modifications, and I've seen these arguments used inside the loops or if then statements on variables and file locations etc.

I'm looking for a place that explains each of the arguments as mentioned above for scripting.

  • 1
    Search for conditional expressions in the man page of your shell, eg zsh Jan 11, 2017 at 17:22
  • 2
    or man test, depending on your OS/distro (only if your shell is not providing a built-in test). Jan 11, 2017 at 17:33
  • "Conditional Expressions" was what i was looking for in the man page. Thanks for your quick reply! Jan 11, 2017 at 20:44

2 Answers 2


I believe you should find everything in details in the man page of your shell (e.g. man bash).

Moreover, bash, for one, has a builtin command named help. Just give the command in parameter. Here the command is [[ and help [[ redirects to the command test (a.k.a. [), therefore help test will give you what you need.

Finally, builtins often have their standalone counterparts in /bin and their are generally provided with a manpage => man [ or man test

  • Perfect!! This is what I needed!! I was originally doing "man -n" etc and getting nowhere. Thank you for providing the answer I needed. I wish I could mark this as the correct answer as well. Jan 11, 2017 at 20:43
  • You can do a man xxx, but only on a command, not on an option. So, you must first identify the command which is the first word after if or while. For bash builtins, use help instead.
    – xhienne
    Jan 11, 2017 at 20:48

you want the TLDP page for BASH,

advanced bash: http://www.tldp.org/LDP/abs/html/index.html

beginner bash: http://tldp.org/LDP/Bash-Beginners-Guide/html/index.html

what you were asking is about file test operators and can be found here: http://www.tldp.org/LDP/abs/html/fto.html

and also bash conditional expressions which can found here: 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}

if [ -e $1 ] && [ -w $1 ]; then
   echo "the file you entered was "$1" and it exists and you have write permission to it"
   echo "condition failed for exist and for write permission"
  • Wow!! Thanks for your help and the resources. Thats exactly what I wanted!!! Thanks much! Jan 11, 2017 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.