Showing posts with label Argument. Show all posts
Showing posts with label Argument. Show all posts

Wednesday, 5 September 2018

Create Alias Command with Parameter in Linux


"Alias" - A shortcut for a command or set of commands

Linux OS provides the facility to have alias command to keep the long and frequent command to very few keystrokes, May be I am being a more cryptic with the lots of jargon words, let's try to understand this way -

When you execute a command "ll" (double Ele) in Linux prompt, it will return the result which is the same as "ls -l" because most of the modern linux os have this alias command (ll) for "ls -l" which is quick and easy.  You can add your customize command in ".bashrc" (dot bashrc) in case of  BASH shell or ".kshrc" in case of KORN shell.



How To:
alias pcs = 'ps -ef'  # this will create an alias named pcs which is equivalent to "ps -ef"

As we can see, we can create lots of alias of frequent commands needed in our day to day work, but avoid the alias which modifies/delete system files.

Now, Coming back to the Original Topic,  Can we create an alias which accepts the arguments, Answer is YES, lets check it our How To --

How To create ALIAS which accept command line parameter:


  • Create a script which will accept the argument and do the task, such as - 
= =

  • Create an alias for this script as - 
==

  • How to use this alias - 
==

and voilĂ  !! we are done, Now you can add so many scripts as alias which accept the parameters, Please share here if you have created something useful for you.





Like the below page to get update  
Facebook Page      Facebook Group      Twitter Feed      Google+ Feed      Telegram Group