-2

I need help with a shell script to display my current IP Address and MAC Address with a "|" in between them like this:

IP Address:  | MAC Address: 

So can this be done easily in a shell script?

iamr00t
  • 1
  • 2
  • 7
    I'm voting to close this question as off-topic because it is not about information security. It might be more on topic on stackoverflow.com because this site is about coding - but they expect to at least try yourself first and help with specific problems instead of doing all the coding for you as you expect here. – Steffen Ullrich Aug 04 '17 at 20:48

1 Answers1

-1

Shell Script:

#!/bin/bash

IF=$(route | grep '^default' | grep -o '[^ ]*$')
IP=$(ip addr show $IF | awk '/inet / {print $2}' | cut -d/ -f 1)
MAC=$(ip link show $IF | awk '/ether/ {print $2}')

echo "IP Address: $IP | MAC Address: $MAC"

Look into grep, awk, and sed to learn more about text processing and doing more tasks like this.

TazerFace
  • 317
  • 3
  • 12