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?
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?
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.