1 |
Arturo 'Buanzo' Busleiman schrieb: |
2 |
|
3 |
> What about |
4 |
> |
5 |
> ip addr show dev eth0 | awk '{print $2}' | grep -v \: | head -n 1 | cut -d'/' -f1 |
6 |
|
7 |
IMO, too many different commands to be elegant... |
8 |
|
9 |
Further: |
10 |
|
11 |
alexander@blatt ~ $ ip addr show dev ra0 |
12 |
bash: ip: command not found |
13 |
|
14 |
But if awk is okay, I'd do: |
15 |
|
16 |
alexander@blatt ~ $ /sbin/ifconfig ra0 | sed -n 2p | sed -e '$!d' | awk -F: '{print $2}' | sed 's| .*||' |
17 |
192.168.1.11 |
18 |
|
19 |
Or if we make the assumption, that the network mask will |
20 |
always start with "255.", we could do: |
21 |
|
22 |
alexander@blatt ~ $ /sbin/ifconfig ra0 | awk -F: '/:255\./{print $2}' | sed 's| .*||' |
23 |
192.168.1.11 |
24 |
|
25 |
Any awk "gurus" around? If so, how to do away with that sed command? |
26 |
|
27 |
Alexander Skwar |
28 |
-- |
29 |
gentoo-user@g.o mailing list |