Can anybody tell me what will this script do? What is the -z on the 3rd line?
Filename=File.txt
X=`ls /home/$Filename`
if [ -z "$X" ]; then
exit
fi
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The
$Filenamevariable now has the valueFile.txt.The
$Xvariable now contains the output of the commandls /home/File.txt. If the file exists, it will contain something, otherwise it will be an empty string.If the value of the variable
$Xis an empty string (meaning that/home/File.txtdoes not exist, otherwise$Xwould contain something), then:This is a pretty awkward way of writing:
-ereturns true if the path exists. You can also check for files (-f), directories (-d), symbolic links (-L), etc. Take a look atman [for more options that can be used with[. You’ll also find-zthere: