Mukesh Chauhan

Just another WordPress.com weblog

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.

March 6, 2009 Posted by | Linux | Leave a comment