I have saved following command in a script called dir
ls -la | egrep '^d'
i saved the file dir under my home/bin directory, which also happens to be in my PATH variable. If i execute dir command from any other directory, it has the effect of a simple ls, but if i copy this file into any folder and then run dir, i get the correct output.
what needs to be done, so that i can run the above script by simply typing dir and it shows me the correct result?
UPDATE: the above works correctly on mac os x, but does not work correctly under linux as explained above.
That is because there already is a command named dir, and it’s got priority over your script. Try giving it a name that is not reserved.