Ubuntu: Is it possible to shorten a unix terminal command to a shorter one? [duplicate]


This question already has an answer here:

Let's say I have this command:

/sbin/ifconfig|grep inet|head -1|sed 's/\:/ /'|awk '{print $3}'  

Is it possible to shorten this to let's say writing host in the command line?


Yes, you can create shell alias, which is exactly what you need:

$ alias mycmd="/sbin/ifconfig|grep inet|head -1|sed 's/\:/ /'|awk '{print $3}'"  

You probably want to have above alias permanent. To achieve this, add the above alias command to the ~/.bashrc file.

Note:If u also have question or solution just comment us below or mail us on toontricks1994@gmail.com
Next Post »