"The Gyzmo" <[EMAIL PROTECTED]> writes: > Hello. I've written a short shell script to change my directory and > display the contents at once because I'm sick of having to do 'cd dir' > then 'ls -l'. My problem is that once the program is done executing, my > directory remains the same. Here's my script: > > #!/bin/bash > cd $1 > ls -lh | more > > How can I solve this problem?
The shell invoked by the script is the one doing the cd'ing. Not your shell. A better faster and generally cool way to do this sort of thing is with functions in your .bashrc (or other login init files) For the the functionality you wanted above it would look like this: cdl () { cd $1;ls -lh|more; } NOTE: The spaces after/before {} are important. The `;' after `more' is vital too. NOTE: `cdl' is just an arbitrary name. It could be anything. With that in .bashrc you would have a new command at the prompt. Type: `cdl dir' And presto: moved and listed. In order to get it into your environment as you write it, you will need to source .bashrc after inserting the line like: source ~/.bashrc You should be able to cut and paste the line above to get the idea of what it will do. Just put it in a file named test for now, to see what it does. (remember to source what ever file you put it in) source test or . test _______________________________________________ Redhat-list mailing list [EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list