On Sat, 30 Mar 2002, The Gyzmo wrote: > 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 problem is that your script is changing the current directory of the subshell it's running in, not your shell. There are two solutions: One is to source the script instead of running it. Type . myscript.sh The period works like an #include directive; it reads the script and processes it in the current shell. The second way is to not use a script at all, but a shell function. man bash for more information about them. ---------------------------------------------------------------------------- DDDD David Kramer [EMAIL PROTECTED] http://thekramers.net DK KD One last warning: don't believe anything that you read in this DKK D document. Every effort has been made to ensure that this document DK KD is incomplete and inaccurate, and I take no responsibility for an DDDD glimmers of correct information that may, by some fluke, be here. UW_IMAP documentation _______________________________________________ Redhat-list mailing list [EMAIL PROTECTED] https://listman.redhat.com/mailman/listinfo/redhat-list