The random address generator is this:
- Code: Select all
openssl rand -hex 6 | sed 's/\(..\)/\1:/g; s/.$//'
My goal is to send the output to a variable for use with:
- Code: Select all
sudo ifconfig en1 lladdr
However, I am having trouble outputting the result of the sed command into a variable. I've tried several different methods of command substitution, piping and variable declarations with no luck.
I don't really understand sed to begin with. I knew how to generate a random string 6 bytes long, I just did not know a way of parsing it in a MAC format. As I researched how to do this, I came across the sed command shown above. That is what actually had prompted me to try creating a script around it automating the generation and assigning of a random MAC address. I have tried for the past couple weeks to study sed and for one reason or another, comprehension of it eludes me. I have tried altering the command slightly to see what it does, but most of the time, it tells me that there is a bad flag in my command. That or I don't understand how the change I made corresponds with the result.
Anyone have any suggestions? Or am I just going about this all wrong? Any tips on making sense of sed?


