Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Possible Duplicate:
Make cd automatically ls

I think that it would be very useful to have a unix utility that combines 'cd' and 'ls' so that when you change your directory, it automatically lists the files in that directory. I have tried to do this using shell scripts, and C programs and a combination of the two, but nothing seems to work, because any 'cd' or 'chdir()' call in a shell script/ c program only changes the directory for that instance (not for the shell).

The psudocode would look like (if it was only this simple!):

cd $1
ls

If anyone has any ideas of how to implement this I would really appreciate it!

Thanks, Kevin

share|improve this question
add comment

marked as duplicate by manatwork, Renan, dogbane, jw013, Mat Oct 2 '12 at 15:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

1 Answer

up vote 1 down vote accepted

in your .bashrc:

cl() { cd "$1" && ls -al; }

you would use cl instead of cd to change directory and then ls -al

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.