#!/bin/bash -e

cd /etc/NetworkManager/system-connections

if [[ $# -gt 0 ]]; then
    newmac=$1
else
    printf "New MAC address: "
    read newmac
fi

for f in *; do
    sed -i "s/mac-address=..:..:..:..:..:../mac-addess=$newmac/" "$f"
done

echo -e "Done. You need to restart the NetworkManager for the effects to take place:"
echo -e "# systemctl restart NetworkManager\n"
