I want to check whether there exist directory named "name" in the current working directory. is it possible to do with ls?
ls -l | grep ^-d
shows just directories but how to specify?
thanks in advance
One should never parse the output of ls. If you are using bash, try this
if [ -d "$DIRECTORY" ]; then
# will enter here if $DIRECTORY exists.
fi
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With