I have a text file, mac.txt, with one line that looks like this:
4a:38:61:e1:71:7c
... and I have a bash script, mask.sh, that simply changes my MAC address:
#!/bin/bash
sudo ifconfig wlan0 down
sudo macchanger -m 16:dx:0b:rc:4a:32 wlan0
sudo ifconfig wlan0 up
And I'm trying to figure out how to write a bash script that will copy the MAC address from mac.txt and replace it with the MAC address in mask.sh, so that it looks like this:
#!/bin/bash
sudo ifconfig wlan0 down
sudo macchanger -m 4a:38:61:e1:71:7c wlan0
sudo ifconfig wlan0 up
I've tried a couple variations with sed, cut, and paste but am too embarrassed to show what I'd tried. I'm still pretty new to this.
sudo macchanger -m $(cat mac.txt) wlan0
will work.$(< mac.txt)
. See for example Understanding Bash's Read-a-File Command Substitution