Forrest logo
back to the [[ tool

shell:warp:ac282

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

This command is a conditional statement in a shell script using the bash notation. It checks if the file specified by the variable ${file} is writable.

Here's a breakdown of the command:

  • [[ and ]] are used as the compound command to perform conditionals in bash.
  • -w is an option that checks if the given file is writable.
  • ${file} is a variable, and its value should contain the path to the file you want to check for writability.

So, when this command is executed, it will return true (exit status 0) if the file specified by ${file} is writable. Otherwise, it will return false (exit status 1).

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