Using awk in Alias Command – CentOS & Red Hat

by | Feb 19, 2016 | Linux, RHEL / CentOS

Its possible to use awk in Alias command. I did that by simply just modifying some parenthesis and there you go, had a working awk command.

All that it required was closing awk in double quotes as opposed to single quotes and forward slash before the “$” variable. This alias command is for printing the default Gateway for an interface.

 alias eth0-gw='route -n | grep eth0 | awk "NR==1{ print \$2 }"'

Related Articles….