greycat 1204559577 learn You need SPACES in between your commands and arguments. E.g.: if [ ! -d "$dir" ] **NOT** if [!-d "$dir] etc. lhunath 1373045571 forget lhunath 1373045575 learn Spaces in bash are important syntax: they separate command names and arguments. foo = bar is NOT AN ASSIGNMENT (runs foo with arguments = and bar), if [-d "$dir"] is NOT A TEST (runs the program [-d). Also remember to quote ALL your expansions to avoid unintentionally syntactical spaces from your data: rm "$file" (NOT rm $file).