Search
 
SCRIPT & CODE EXAMPLE
 

SHELL

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. 
Comment

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
Comment

PREVIOUS NEXT
Code Example
Shell :: break line in md file 
Shell :: ubuntu command to check all network interfaces with IPv4 
Shell :: bash string interpolation 
Shell :: git set head to commit 
Shell :: check cuda nn version 
Shell :: git SSL certificate problem: self signed certificate 
Shell :: kubernetes /bin/bash 
Shell :: ssh login windows 
Shell :: video converter for ubuntu 
Shell :: composer install ubuntu 20.04 
Shell :: where is tomcat installed on mac 
Shell :: linux create directory with permissions 
Shell :: how to install gimp in ubuntu 
Shell :: bash get username 
Shell :: Go install /linux 
Shell :: what are the ubuntu packages required for laravel to be installed 
Shell :: install wordpress on ubuntu 20.04 
Shell :: docker container name 
Shell :: wsl install 
Shell :: start fast api server 
Shell :: install packages from jupyter notebook 
Shell :: how to change branch name in github 
Shell :: Looping over a file lines in bash 
Shell :: ubuntu alien install 
Shell :: ubuntu dns config 
Shell :: sudo doesnt work on windows 
Shell :: linux DNS_PROBE_FINISHED_NXDOMAIN 
Shell :: pip upgrade all 
Shell :: powershell webrequest 
Shell :: kill tomcat ubuntu 
ADD CONTENT
Topic
Content
Source link
Name
8+6 =