Reputation: 177
I have a directory and a file with similar name. i.e. filename --> test_16.4 and directoryName --> test_16.43
if [ -d test_* ]; then
echo " directory exists!!!"
else
echo "directory doesn't exists!!!"
fi
This returns "directory doesn't exists!!!" as it checks the condition with filename. how can i make this work?
Upvotes: 1
Views: 32
Reputation: 88644
Replace *
with */
to get only directories.
For a quick test see output of:
echo test_*
echo test_*/
Upvotes: 2