I was actually just using `grep .` to discard empty lines. The `grep -v '^;'` would have only left lines with answers after it discarded lines starting with `;`. That and the empty lines.
I could have combined `grep -v '^;'` and `grep .` as a nice simple `grep '^[^;]'`
Ahh. I was working from memory, I forgot about the empty lines it returns. That's what I get for replying from my phone. :)
However, it's still better to just have the `dig` command return only the necessary information via the +short or +noall +answer flags, rather than parsing the full output.
dash is only allowed in the middle. labels can't start or stop with it. so it wouldn't affect the command arguments.
The labels must follow the rules for ARPANET host names. They must
start with a letter, end with a letter or digit, and have as interior
characters only letters, digits, and hyphen. There are also some
restrictions on the length. Labels must be 63 characters or less.
If matching everything was intended then you don't need it at all:
Will strip out the lines beginning with a semi-colon.However, parsing the output of `dig` this way is not needed. It can be ran to only return the answer, for example:
Or if you just want the IP for that record: