How to get lan ip address as output in Manjaro in the terminal?

I have a script which I used to use in ubuntu. It got my lan ip address using the command hostname -I. I would get an output like 192.168.1.99 as a string which I can use somewhere else.

However, with Manjaro, the command doesn’t exist, when I tried hostname -i, (lowercase) but i get 127.0.1.1. I even installed the dnsutils.

Is there a way I can get my address on the LAN as an output from any command / tool in Manjaro?

1 Like

ip
example:
ip address show

2 Likes

the whole infos : ‘nmcli device show’
with grep you can filter
nmcli device show | grep IP4.ADDRESS
or save it to a temporary file
nmcli device show | grep IP4.ADDRESS > test.txt
from there you can parse the output with head, tail or whatever you want

1 Like

Good advice: I would add, in this case, eg, that I feed the output to head, awk, rev and cut (and again rev):

nmcli device show | grep IP4.ADDRESS | head -1 | awk '{print $2}' | rev | cut -c 4- | rev

And so I get 192.168.1.3 instead of 127.0.0.1