Horje
shell if "-z" Code Example
if -z in bash
The -z flag causes test to check whether a string is empty. 
Returns true if the string is empty, false if it contains something. 
shell if "-z"
# Returns true if string empty.
# E.G: file.txt does not exist

EXISTS=$(cat file.txt 2> /dev/null)

if [ -z "${EXISTS}" ]; then
	echo "Does not exist"
else
    echo "Exist!"
fi

# Output: 
# Does not exist




Shell

Related
vscode connect gitlens to gitlab Code Example vscode connect gitlens to gitlab Code Example
laravel install valet Code Example laravel install valet Code Example
connect vscode to gitlab Code Example connect vscode to gitlab Code Example
Recover accidentally deleted files by git reset hard Code Example Recover accidentally deleted files by git reset hard Code Example
powershell suppress error Code Example powershell suppress error Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
9