Home > shell > Change Directory and List Files

Change Directory and List Files

October 2Hits:1
Advertisement

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

Answers

in your .bashrc:

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

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

Related Articles

Copyright (C) 2018 ceus-now.com, All Rights Reserved. webmaster#ceus-now.com 14 q. 0.622 s.