I am making some aliases for my terminal to output different IP addresses. Two out of three of them work just fine, but my one for default gateway won't return a clean response.
alias inet="hostname -I | awk '{print $3}'"
returns: 192.168.xxx.xx
as intended
alias pubip="curl ifconfig.me"
returns: 354.xxx.xx.xx
as intended
However the alias I made to return the default gateway ip
alias def="ip r | grep default | awk '{print $3}'"
returns : default via 192.168.xxx.xxx dev eth0
I use the same line in the terminal and it will return just the default gateway as intended.
But when it is stored as an alias the "awk" portion of the script doesnt work.
Can I not pipe twice in an alias? Is there something else wrong in my code?