Reputation: 5626
I am new to scripting and I found following expression in a script.
if [ -d $_path ];then
could someone help me to understand what does -d $_path means inside if statement?
Thanks in advance for any help.
Upvotes: 1
Views: 360
Reputation: 102056
It checks whether the value of _path
is a directory. Note that _path
is a variable and the $
is the get-value-of operation (sort of); it is not looking for a folder called $_path
.
As an example:
> mkdir dir
> touch file
> ls
dir/ file
> _path=dir # set the variable `_path`
> if [ -d $_path ]; then echo yes; else echo no; fi
yes
> _path=file
> if [ -d $_path ]; then echo yes; else echo no; fi
no
Upvotes: 1
Reputation: 10756
It's a test for whether _path is a directory.
Note bash and DOS are two entirely different things.
Upvotes: 2