10.3.26 isDir (evaluates existence of directory)
Syntax
isDir directory-path-name
Description
This command evaluates whether the file specified for argument exists. File is not considered not to be directory.
This command outputs 1 in the following cases:
-
Directory exists.
This command outputs 0.
-
Directory does not exist.
Arguments
- directory-path-name
-
This command specifies the path name of the directory to be evaluated.
Output to the standard output
1 or 0.
Return codes
Return code |
Meaning |
---|---|
0 |
Normal termination |
Not less than 1 |
Termination with an error |
Examples
If the directory test exists and directory prog does not exist: isDir test # "1" is output. isDir prog # "0" is output. # If the directory dir1 does not exist, create dir1. result=$(isDir dir1) if [[ $result -eq 0 ]]; then mkdir dir1 fi