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 :: managed mode linux kali 
Shell :: qemu specify raw 
Shell :: colcon build limit cores 
Shell :: apache2 mod_jk proxy to tomcat connector 
Shell :: show seconds in ubuntu 20.04 
Shell :: copy a file from local machine to docker container 
Shell :: python code in bash script 
Shell :: kubectl update field 
Shell :: asdf install nodejs 12 m1 
Shell :: install svgo linux 
Shell :: dmesg watch command linxu 
Shell :: how to hide log in background job in linux 
Shell :: merge two branches git 
Shell :: add vimplug 
Shell :: import fuzzywuzzy module jupyter notebook 
Shell :: get-docke 
Shell :: nextcloud config.php location docker 
Shell :: Check Available SSH Keys on Your Computer 
Shell :: powershell add to path 
Shell :: what is linux 
Shell :: gitlab gitignore not working 
Shell :: python rioxarray install 
Shell :: platform cli 
Shell :: libodbc1 2.3.7 ubuntu 
Shell :: ubuntu check usb connections 
Shell :: git create new repository 
Shell :: send file to remote computer linux 
Shell :: break a symbolic link in linux 
Shell :: ubuntu install all language packs 
Shell :: where is office folder 
ADD CONTENT
Topic
Content
Source link
Name
9+6 =