in reply to how to check
Your test will be true if $path is the path of a file. You can use '-d' to test if it is the path of a directory. Too see all the tests you can read -X