Skip to content

Instantly share code, notes, and snippets.

@DanielSSilva
Created July 25, 2017 13:16
Show Gist options
  • Save DanielSSilva/114ad8a59b533e9bdf1aaca268e395db to your computer and use it in GitHub Desktop.
Save DanielSSilva/114ad8a59b533e9bdf1aaca268e395db to your computer and use it in GitHub Desktop.
Get Mac Address bash script
#!/bin/bash
FLAG="/path/to/log/getMacAddress.log"
if [ ! -f $FLAG ]; then
echo "Getting Mac address"
ifconfig eth0 | grep -Po 'HWaddr \K.*$' > "/path/to/destinationFile/$(cat /etc/hostname).txt"
touch $FLAG
fi
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment