My scrapbook about anything which I learned or want to remember, Sometime about tech tips, thoughts and rambling. If you find anything useful don't forget to give thumbs-up :)

Breaking

Tuesday, September 4, 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     


Disclaimer

The postings on this site are my own and don't necessarily represent IBM's or other companies positions, strategies or opinions. All content provided on this blog is for informational purposes and knowledge sharing only.
The owner of this blog makes no representations as to the accuracy or completeness of any information on this site or found by following any link on this site. The owner will not be liable for any errors or omissions in this information nor for the availability of this information. The owner will not be liable for any losses, injuries, or damages from the display or use of his information.