0

I'm interested in:

if [ -z "${var// }" ]...

if [ -d $dir ]...

More precisely, what is -z and -d? How can I call it and where can I read about this "keys"? And where can i find a full list of this "keys"?

Pro
  • 611
  • 1
  • 5
  • 15

3 Answers3

1

Look at the manpage for test

man test
Rob Hales
  • 4,750
  • 1
  • 18
  • 31
1

-z variable will check condition if a variable is NULL then the condition will be TRUE if NOT then it will go to else part of if condition.

-d directory_name will check if a directory name which is given next to it is present or not. If directory is present then condition will be TRUE or it will be FALSE.

From man test

-z STRING

the length of STRING is zero

-d FILE

FILE exists and is a directory

RavinderSingh13
  • 117,272
  • 11
  • 49
  • 86
1

in bash manual invoked using

 man -a bash

a section called CONDITIONAL EXPRESSIONS which covers what you are looking for, in fact there are a whole bunch of basic to advanced concepts in there to look for.

asio_guy
  • 3,524
  • 2
  • 17
  • 34