Forrest logo
back to the [[ tool

shell:warp:25e37

Check if file exists and is executable by the current process
$ [[ -x ${file} ]]
try on your machine

The command [[ -x ${file} ]] is a test expression using the double square brackets [[ for conditional testing. It checks whether a file specified by the variable file is executable. Here's a breakdown of the different components:

  • [[: The opening double square brackets indicate the start of a test expression.
  • -x: This option checks if the file is executable. It returns true if the file exists and execute permission is granted to the current user. If the file is a directory, it checks if the current user has search (access) permission.
  • ${file}: This is a variable placeholder holding the name or path to the file you want to check.
  • ]]: The closing double square brackets mark the end of the test expression.

Overall, the command checks if the file specified by file is executable and returns either true or false as the result.

This explanation was created by an AI. In most cases those are correct. But please always be careful and never run a command you are not sure if it is safe.
back to the [[ tool