Languages
[Edit]
EN

Bash - check if directory exists

0 points
Created by:
Hiba-Tate
548

In this article, we would like to show you how to check if directory exists in Bash.

Quick solution:

Hint:

If you want to check if directory doesn't exist, go to this article.

 

Practical example

Edit

In this example, we create a script into which we pass a path to directory (test_directory in Usage example) as an argument from bash console.

Run in command line:

Note:

[ -d "path/to/directory" ] is equivalent to test -d "/path/to/directory".

 

See also

Edit
  1. Bash - check if directory doesn't exist

1
Donate to Dirask
Our content is created by volunteers - like Wikipedia. If you think, the things we do are good, donate us. Thanks!
Join to our subscribers to be up to date with content, news and offers.
Native Advertising
🚀
Get your tech brand or product in front of software developers.
For more information Contact us
Dirask - we help you to
solve coding problems.
Ask question.

❤️💻 🙂

Join