As Mr. C. said, you cannot write a script to change the directory because it runs in a child process, which cannot modify your interactive shell's environment (a child cannot modify the environment of the parent).
However, you can set an alias in your .profile, which executes within your interactive shell - here you can change the working directory.
e.g. in your $HOME/.profile add these lines:
Code:
. /opt/osmf/config/env/osmf-http.env
alias oralog='cd "$ORACLE_HOME/opmn/logs"'
Of course, you don't have to call it "oralog" - use whatever you like.
One word of warning - editing your .profile is potentially risky. This file is read whenever a login shell is created. If you write something wrong in this file, it can make it so you will not be able to log in again (e.g. putting the "exit" command in the .profile - although there are many subtler problems which can occur).
To guard against this, I propose the following method to edit your .profile:
- In one terminal, edit the .profile. save your changes but leave the editor running.
- With the .profile still open in the first terminal, open another terminal and source the modified .profile with this command:
- After sourcing the .profile, check that your changes seem OK - in our case that the alias works as expected
- Only when you know the changes are successful, close the editor.
This method is probably a bit over-cautious, but it is a good idea if you are not a confident scripting programmer.