nslookup -q=srv SOME_ADDRESS, and want to store the returned addresses inside an array.
Server: 123.456.789.123 Address: 123.456.789.123#12 SOME_ADDRESS service = 0 0 1234 address-1.i.want. SOME_ADDRESS service = 0 0 1234 address-2.i.want. SOME_ADDRESS service = 0 0 1234 address-3.i.want.
I'm still learning regex, I got the strings into an array with:
array=($(nslookup -q=srv SOME_ADDRESS | grep -o ' [a-z0-9.-]*[a-z0-9].$'))
which gives me
[ ]address-3.i.want. where the
[ ] is a white-space.
How would I match only
adress-3.i.want without the space at the start and
. at the end? (with regex, not by removing characters from the result string. I know how to do it adding another
cut via pipes, but I'm sure I could just edit the regex to do what I want)