Shell scripting: alias tutorial

This is a neat little utility on the bash shell. Aliases allow a string to be substituted for a word when it is used as the first word of a simple command.

alias today='date +"%A, %B %-d, %Y"' #Tuesday, October 18, 2011

And how do you undo this alias? Simple.

unalias today

Now typing today on the terminal returns “Tuesday, October 18, 2011”. These are some neat little tricks I think are required on any linux box.

Use alias to fix missing space typos.

alias cd..='cd ..'
alias ..='cd ..'

Display the working directory.

alias .='echo $PWD'

Prevent accidental deletions by making rm interactive.

alias rm='rm -i'

I hope this will get you started! šŸ™‚

Shell scripting: alias tutorial

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s