Friday, March 6, 2009

Creating alias in bash

You can alias any command in your .bashrc file to create shortcut.

For ex - alias l='ls -ltr' will create a alias for ls command with -ltr options. Now use only l to invoke this command.

Combine two or more commands in one alias,

alias cdh="cd <home>; ls -l"

You can see aliases set by you by invoking 'alias' command in shell.

A more complex example for creating a shortcut,

rmdir()
{
rm -rf  $1 > /dev/null &
}

$> rmdir test will remove test directory.

No comments:

Post a Comment