Reputation: 139
I understand that its going to a directory and recursively and forcefully removing ./tmp. My issue is with the "-d ./tmp". What does the -d do and why would the "./" be in front of tmp?
Thanks in advance
cd $WORKING_DIR
if [ -d ./tmp}; then
rm -rf ./tmp
fi
Upvotes: 0
Views: 30
Reputation: 289725
It checks whether ./tmp
exists and is a directory. In that case, it removes it.
From man test
:
-d FILE
FILE exists and is a directory
By the way, the syntax has errors:
if [ -d ./tmp}; then
^
needs space and ] instead of }
Correctly:
if [ -d ./tmp ]; then
Upvotes: 1