10.3.29 isNormalFile (evaluates existence of a regular file)
Syntax
isNormalFile file-path-name
Description
This command verifies whether the regular file specified for argument exists. Directory is not considered not to be file.
This command outputs 1 in the following cases:
-
The regular file exists.
This command outputs 0.
-
The regular file does not exist.
Arguments
- file-path-name
-
This command specifies the path name of the file 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 regular file log.txt exists and the regular file tmp.txt does not exist: isNormalFile log.txt # "1" is output. isNormalFile tmp.txt # "0" is output. If the directory test exists and directory prog does not exist: isNormalFile test # "0" is output. isNormalFile prog # "0" is output. # If the regular file file1 does not exist, create file1. result=$(isNormalFile file1) if [[ $result -eq 0 ]]; then touch file1 fi