I was wonder with someone can help me:
if [ -z $1 ]; then
user=$(whoami)
else
if [ ! -d "/home/$1" ]; then
echo "Requested $1 user home directory doesn't exist."
exit 1
fi
user=$1
fi
I was studying some bash commands when I saw two commands: -z
and -d
. I know what they do (first check for blank variable and the second check for existence directory). My question is how I can find descriptions about these commands (i.g man page -d/-z). They can be only used with if-else statement?
man bash
– Pedro Gabriel Lima Jun 01 '18 at 12:38help test
. – fd0 Jun 01 '18 at 12:40help test
is a summary for conditional expression! – Pedro Gabriel Lima Jun 01 '18 at 12:46[
syntax... – Jeff Schaller Jun 01 '18 at 12:46-z
and-d
, as they are not commands.-z
and-d
are arguments to the command[
. – William Pursell Jun 01 '18 at 14:08