The Bash Shell,continued...
Tilde Expansion
Another neat thing that bash provides is what
is called Tilde Expansion. The tilde key (~) on it's own is expanded
out to the user's home directory, for example. You can see this
by issuing a 'cd ~' on your command line. Here is a list of expansions
that bash will give you:
~ expands
to $HOME
~bob expands to bob's home
directory
~+ $PWD
~- $OLDPWD
These expansions basically replace themselves on
the command line with the contents of the second column above.
Once the command has been expanded, bash executes it.
Aliases
One of the things I could not do without is
the alias command. If you enter any aliases, bash will fill out
the text of the alias name with whatever the alias contents is
before executing the command.
For example, when I use ls, I like to see
my directory listing in a certain way. Colors, for example, are
good. I also like slashes (/) at the end of directory names just
to show they are directories, and I also like to view all files
starting with a full stop (.) in my listings.
So instead of typing 'ls -Aop' every single time
I want a dir listing, I just use an alias so that -Aop becomes
my default. I enter the command:
alias ls='ls -Aop'
And from then on, bash uses that alias as
my default command. Whenever I enter the alias name (in this case
'ls'), bash expands that out to 'ls -Aop'automatically for me.
If I want to remove the alias, I use 'unalias
ls'. Alternatively, I can opt to type 'unalias -a' to remove all
aliases I have set.
More on the bash shell --->>