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?
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.
$
in the awk field i.e. awk '{print \$3}'"
to prevent the shell from expanding it during alias creation
– steeldriver
Oct 30 '14 at 11:29
~/.bashrc
search for it on askubuntu should give you plenty of results. – Jacob Vlijm Oct 30 '14 at 10:44