Skip to main content

Bash file test operators

Ref

| Operator | Description
|:-- |:--
| -b file | file is a block special file
| -c file | file is a character special file
| -d file | file is a directory
| -f file | file is an ordinary file as opposed to a directory or special file
| -g file | file has its set group ID (SGID) bit set
| -k file | file has its sticky bit set
| -p file | file is a named pipe
| -t file | file descriptor is open and associated with a terminal
| -u file | file has its Set User ID (SUID) bit set
| -r file | file is readable
| -w file | file is writable
| -x file | file is executable
| -s file | file has size greater than 0
| -e file | file exists; is true even if file is a directory