Skip to main content
added 293 characters in body
Source Link
b0red
  • 73
  • 1
  • 7

I'm trying to format the output from the following command;

MYIP=(/sbin/ifconfig $(getnic) | awk '/inet/ { print $2 } ' | sed -e s/addr://); echo $MYIP

which generates the following output;

172.30.0.1 fe80::42:c5ff:fecd:f09f 172.31.0.1 fe80::42:47ff:fe57:2f0d 172.17.0.1 fe80::42:a1ff:fe4e:2508 127.0.0.1 ::1 fe80::2887:fcff:fe19:e54b fe80::bc99:3aff:fe46:dcab fe80::b090:4cff:fecb:3dc4 fe80::9c0f:6dff:fe6b:6c71 fe80::808f:5fff:febb:2669 fe80::f851:23ff:fee4:c87a fe80::4c97:24ff:fe04:ea02 fe80::4cde:e2ff:feb7:4784 fe80::c4fc:4aff:fe67:1863 192.168.1.134 fe80::d1f1:947f:9370:74ca

How do I make it look nicer, just with each ipadress on a separate line?

Edit: clarification; for now I just want all ip's on a separate line, one each. Would be noce to strip out the v6 numbers, but htatäs really not important. Would be a bonux though.

I've tried with tr, sed, awk but I guess I'm doing something wrong or using the wrong command. My thought was just to add another pipe at the end that does some kind of word wrangling magic.

EDIT: This is the complete function;

function myip() {
    MY_IP=$(/sbin/ifconfig $(getnic) | awk '/inet / { print $2 } ' | sed -e s/addr://| sort)
    echo -e ${MY_IP:-"Not connected"}
}

But it still won't print linebreaks. Working on that. Thanx for all input

I'm trying to format the output from the following command;

MYIP=(/sbin/ifconfig $(getnic) | awk '/inet/ { print $2 } ' | sed -e s/addr://); echo $MYIP

which generates the following output;

172.30.0.1 fe80::42:c5ff:fecd:f09f 172.31.0.1 fe80::42:47ff:fe57:2f0d 172.17.0.1 fe80::42:a1ff:fe4e:2508 127.0.0.1 ::1 fe80::2887:fcff:fe19:e54b fe80::bc99:3aff:fe46:dcab fe80::b090:4cff:fecb:3dc4 fe80::9c0f:6dff:fe6b:6c71 fe80::808f:5fff:febb:2669 fe80::f851:23ff:fee4:c87a fe80::4c97:24ff:fe04:ea02 fe80::4cde:e2ff:feb7:4784 fe80::c4fc:4aff:fe67:1863 192.168.1.134 fe80::d1f1:947f:9370:74ca

How do I make it look nicer, just with each ipadress on a separate line?

Edit: clarification; for now I just want all ip's on a separate line, one each. Would be noce to strip out the v6 numbers, but htatäs really not important. Would be a bonux though.

I've tried with tr, sed, awk but I guess I'm doing something wrong or using the wrong command. My thought was just to add another pipe at the end that does some kind of word wrangling magic.

I'm trying to format the output from the following command;

MYIP=(/sbin/ifconfig $(getnic) | awk '/inet/ { print $2 } ' | sed -e s/addr://); echo $MYIP

which generates the following output;

172.30.0.1 fe80::42:c5ff:fecd:f09f 172.31.0.1 fe80::42:47ff:fe57:2f0d 172.17.0.1 fe80::42:a1ff:fe4e:2508 127.0.0.1 ::1 fe80::2887:fcff:fe19:e54b fe80::bc99:3aff:fe46:dcab fe80::b090:4cff:fecb:3dc4 fe80::9c0f:6dff:fe6b:6c71 fe80::808f:5fff:febb:2669 fe80::f851:23ff:fee4:c87a fe80::4c97:24ff:fe04:ea02 fe80::4cde:e2ff:feb7:4784 fe80::c4fc:4aff:fe67:1863 192.168.1.134 fe80::d1f1:947f:9370:74ca

How do I make it look nicer, just with each ipadress on a separate line?

Edit: clarification; for now I just want all ip's on a separate line, one each. Would be noce to strip out the v6 numbers, but htatäs really not important. Would be a bonux though.

I've tried with tr, sed, awk but I guess I'm doing something wrong or using the wrong command. My thought was just to add another pipe at the end that does some kind of word wrangling magic.

EDIT: This is the complete function;

function myip() {
    MY_IP=$(/sbin/ifconfig $(getnic) | awk '/inet / { print $2 } ' | sed -e s/addr://| sort)
    echo -e ${MY_IP:-"Not connected"}
}

But it still won't print linebreaks. Working on that. Thanx for all input

added 182 characters in body
Source Link
b0red
  • 73
  • 1
  • 7

I'm trying to format the output from the following command;

MYIP=(/sbin/ifconfig $(getnic) | awk '/inet/ { print $2 } ' | sed -e s/addr://); echo $MYIP

which generates the following output;

172.30.0.1 fe80::42:c5ff:fecd:f09f 172.31.0.1 fe80::42:47ff:fe57:2f0d 172.17.0.1 fe80::42:a1ff:fe4e:2508 127.0.0.1 ::1 fe80::2887:fcff:fe19:e54b fe80::bc99:3aff:fe46:dcab fe80::b090:4cff:fecb:3dc4 fe80::9c0f:6dff:fe6b:6c71 fe80::808f:5fff:febb:2669 fe80::f851:23ff:fee4:c87a fe80::4c97:24ff:fe04:ea02 fe80::4cde:e2ff:feb7:4784 fe80::c4fc:4aff:fe67:1863 192.168.1.134 fe80::d1f1:947f:9370:74ca

How do I make it look nicer, just with each ipadress on a separate line?

Edit: clarification; for now I just want all ip's on a separate line, one each. Would be noce to strip out the v6 numbers, but htatäs really not important. Would be a bonux though.

I've tried with tr, sed, awk but I guess I'm doing something wrong or using the wrong command. My thought was just to add another pipe at the end that does some kind of word wrangling magic.

I'm trying to format the output from the following command;

MYIP=(/sbin/ifconfig $(getnic) | awk '/inet/ { print $2 } ' | sed -e s/addr://); echo $MYIP

which generates the following output;

172.30.0.1 fe80::42:c5ff:fecd:f09f 172.31.0.1 fe80::42:47ff:fe57:2f0d 172.17.0.1 fe80::42:a1ff:fe4e:2508 127.0.0.1 ::1 fe80::2887:fcff:fe19:e54b fe80::bc99:3aff:fe46:dcab fe80::b090:4cff:fecb:3dc4 fe80::9c0f:6dff:fe6b:6c71 fe80::808f:5fff:febb:2669 fe80::f851:23ff:fee4:c87a fe80::4c97:24ff:fe04:ea02 fe80::4cde:e2ff:feb7:4784 fe80::c4fc:4aff:fe67:1863 192.168.1.134 fe80::d1f1:947f:9370:74ca

How do I make it look nicer, just with each ipadress on a separate line?

I've tried with tr, sed, awk but I guess I'm doing something wrong or using the wrong command. My thought was just to add another pipe at the end that does some kind of word wrangling magic.

I'm trying to format the output from the following command;

MYIP=(/sbin/ifconfig $(getnic) | awk '/inet/ { print $2 } ' | sed -e s/addr://); echo $MYIP

which generates the following output;

172.30.0.1 fe80::42:c5ff:fecd:f09f 172.31.0.1 fe80::42:47ff:fe57:2f0d 172.17.0.1 fe80::42:a1ff:fe4e:2508 127.0.0.1 ::1 fe80::2887:fcff:fe19:e54b fe80::bc99:3aff:fe46:dcab fe80::b090:4cff:fecb:3dc4 fe80::9c0f:6dff:fe6b:6c71 fe80::808f:5fff:febb:2669 fe80::f851:23ff:fee4:c87a fe80::4c97:24ff:fe04:ea02 fe80::4cde:e2ff:feb7:4784 fe80::c4fc:4aff:fe67:1863 192.168.1.134 fe80::d1f1:947f:9370:74ca

How do I make it look nicer, just with each ipadress on a separate line?

Edit: clarification; for now I just want all ip's on a separate line, one each. Would be noce to strip out the v6 numbers, but htatäs really not important. Would be a bonux though.

I've tried with tr, sed, awk but I guess I'm doing something wrong or using the wrong command. My thought was just to add another pipe at the end that does some kind of word wrangling magic.

Source Link
b0red
  • 73
  • 1
  • 7

format output with what?

I'm trying to format the output from the following command;

MYIP=(/sbin/ifconfig $(getnic) | awk '/inet/ { print $2 } ' | sed -e s/addr://); echo $MYIP

which generates the following output;

172.30.0.1 fe80::42:c5ff:fecd:f09f 172.31.0.1 fe80::42:47ff:fe57:2f0d 172.17.0.1 fe80::42:a1ff:fe4e:2508 127.0.0.1 ::1 fe80::2887:fcff:fe19:e54b fe80::bc99:3aff:fe46:dcab fe80::b090:4cff:fecb:3dc4 fe80::9c0f:6dff:fe6b:6c71 fe80::808f:5fff:febb:2669 fe80::f851:23ff:fee4:c87a fe80::4c97:24ff:fe04:ea02 fe80::4cde:e2ff:feb7:4784 fe80::c4fc:4aff:fe67:1863 192.168.1.134 fe80::d1f1:947f:9370:74ca

How do I make it look nicer, just with each ipadress on a separate line?

I've tried with tr, sed, awk but I guess I'm doing something wrong or using the wrong command. My thought was just to add another pipe at the end that does some kind of word wrangling magic.