------------------------------------------------------------------------ finding if a file exists and take decisions ------------------------------------------------------------------------ Ambreesh Khurana posed "Out of 100 available directories, check if a file x exists in it. If it does, execute a command y, otherwise execute another command z." There are, I suspect, at least half a dozen ways, of solving this problem. I will start using "find" because it is the best tool for file searching. "find" allows a variety of searches, including recursive searches. $ ls FileExists.txt $ find . -name FileExists.txt ./FileExists.txt $ find -name Khurana #returns null string named file does not exist We are now set $ if [[ $(find . -name Khurana) ]];then; echo "file found"; else; echo "not found"; fi Note that the "test" construct has to have one or more space on either side of "[[" and one or more space on the left side of "]]". Sorry, this is Unix arcana.