Session Variables
Variables that control your environment.
- $HOME – holds your home directory; change only if you like strange results.
- $PATH – holds the list of directories where your shell will look for programs. Add a “:.” at the end to include your pwd.
- $PWD – Yes, it is you pwd.
- $CDPATH – Controls order of search when using relative path. Put “.:” first if you want to search pwd first.
- $TERM – Set in your .profile
- $TZ- Time zone
- $PS1 – Controls the prompt.In bash, special escaped characters can be used to display information, such as:
- \wpwd\h host\v shell version
- \s shell\d date\t time
- \h host\u user
- $PS2 – Controls the secondary prompt
The exec Command
The exec command can be used to replace the current program with another or to redirect <std-in> or <std-out> for your session.
- For example:
- “exec sh”, starts a Bourne shell in the place of your current shell with the SAME PID.
- “exec > my_test” would set <std-out> to the file my_test.
- “exec > /dev/tty” would set <std-out> to the terminal.
The (...) and {...;} Contructs
(...) can be used to group a set of commands and redirect input and output. Commands are run in a separate shell.
- Example: ( prog1; prog2; prog3 ) > my_out &
{...; } can be used the same way, except it runs in the current shell.
- The last command must be followed by a semi-colon(;) and
- the left brace( { ) must be follow by a space.