Yige

Yige

Build

The meaning of -z to -d in the if statement of shell conditional expressions.

Meaning of -z to -d in if condition judgment in shell#

  • [ -a FILE ] True if FILE exists.
  • [ -b FILE ] True if FILE exists and is a block special file.
  • [ -c FILE ] True if FILE exists and is a character special file.
  • [ -d FILE ] True if FILE exists and is a directory.
  • [ -e FILE ] True if FILE exists.
  • [ -f FILE ] True if FILE exists and is a regular file.
  • [ -g FILE ] True if FILE exists and has the SGID set.
  • [ -h FILE ] True if FILE exists and is a symbolic link.
  • [ -k FILE ] True if FILE exists and has the sticky bit set.
  • [ -p FILE ] True if FILE exists and is a named pipe (FIFO).
  • [ -r FILE ] True if FILE exists and is readable.
  • [ -s FILE ] True if FILE exists and is not empty.
  • [ -t FD ] True if file descriptor FD is open and points to a terminal.
  • [ -u FILE ] True if FILE exists and has the SUID (set user ID) set.
  • [ -w FILE ] True if FILE exists and is writable.
  • [ -x FILE ] True if FILE exists and is executable.
  • [ -O FILE ] True if FILE exists and is owned by the effective user ID.
  • [ -G FILE ] True if FILE exists and is owned by the effective group ID.
  • [ -L FILE ] True if FILE exists and is a symbolic link.
  • [ -N FILE ] True if FILE exists and has been modified since it was last read.
  • [ -S FILE ] True if FILE exists and is a socket.
  • [ FILE1 -nt FILE2 ] True if FILE1 exists but FILE2 does not.
  • [ FILE1 -ot FILE2 ] True if FILE1 is older than FILE2, or FILE2 exists and FILE1 does not.
  • [ FILE1 -ef FILE2 ] True if FILE1 and FILE2 point to the same device and inode number.
  • [ -o OPTIONNAME ] True if the shell option "OPTIONNAME" is enabled.
  • [ -z STRING ] True if the length of "STRING" is zero.
  • [ -n STRING ] or [ STRING ] True if the length of "STRING" is non-zero.
Loading...
Ownership of this post data is guaranteed by blockchain and smart contracts to the creator alone.