file-test

Bash -x — execute or search access test

For a regular file this checks execute access; for a directory it checks search/traversal access. It does not validate executable format or promise successful execution. The sample file is not executed. Run the example independently in a fresh private directory. Expected output (one item per line): before=1; after=0.

Formal Syntax & Structure

bash syntaxbash
[[ -x path ]]

Parameters & Attributes

NameTypeDescription
pathpathFile or directory pathname to inspect.

Return Value

exit status

0 for a true condition; 1 for a false condition. Invalid expressions may fail differently.

Working Example

Example Snippetbash
touch samplechmod 600 sample[[ -x sample ]]; printf 'before=%s\n' "$?"chmod 700 sample[[ -x sample ]]; printf 'after=%s\n' "$?"
Bash Reference