`awk` an address using blueutil

Hey all!

Long story short, I am trying to script some an automation using blueutil and have been hitting my head against the following problem:

  • how to I awk the address from the following output:
Blueutil output
address: 10-28-74-3a-d4-cd, not connected, not favourite, paired, name: "TOZO T6", recent access date: 2024-11-13 20:27:11 +0000
address: 48-e1-5c-c3-0c-2c, not connected, not favourite, paired, name: "User’s Magic Keyboard", recent access date: 2024-11-13 20:27:11 +0000
address: f4-b6-88-7e-6a-0a, not connected, not favourite, paired, name: "user42", recent access date: 2024-11-13 20:27:11 +0000
address: d1-01-d1-13-b7-75, not connected, not favourite, paired, name: "EPOMAKER EK21-1", recent access date: 2024-11-13 20:27:11 +0000
address: 60-7e-c9-b8-08-65, not connected, not favourite, paired, name: "iPhone", recent access date: 2024-11-13 20:27:11 +0000
address: 5c-f5-da-7c-ca-b9, not connected, not favourite, paired, name: "Bender", recent access date: 2024-11-13 20:27:11 +0000
address: 14-95-ce-56-29-e0, not connected, not favourite, paired, name: "Matthew’s Apple Watch", recent access date: 2024-11-13 20:27:11 +0000
address: 88-e9-fe-6c-85-78, not connected, not favourite, paired, name: "user42's MacBook12in", recent access date: 2024-11-13 20:27:11 +0000
address: 5c-f5-da-80-59-1c, not connected, not favourite, paired, name: "iPad", recent access date: 2024-11-13 20:27:11 +0000
address: 04-52-f3-61-12-74, not connected, not favourite, paired, name: "User’s iPad", recent access date: 2024-11-13 20:27:11 +0000
address: 2c-f0-a2-f1-14-ed, not connected, not favourite, paired, name: "User’s MacBook Air", recent access date: 2024-11-13 20:27:11 +0000
address: 6c-4a-85-67-fd-ac, not connected, not favourite, paired, name: "DEP-SERIALNUM", recent access date: 2024-11-13 20:27:11 +0000
address: 6c-e5-c9-1f-7d-28, not connected, not favourite, paired, name: "iPad", recent access date: 2024-11-13 20:27:11 +0000
address: 0c-51-01-8f-a3-40, not connected, not favourite, paired, name: "iPad", recent access date: 2024-11-13 20:27:11 +0000
address: ec-ce-d7-83-ba-7b, not connected, not favourite, paired, name: "iPhone", recent access date: 2024-11-13 20:27:11 +0000
address: d9-d0-f0-1f-b1-03, connected (master, 0 dBm), not favourite, paired, name: "MX Master 3S M", recent access date: 2024-11-13 20:27:11 +0000
address: 34-ab-37-e1-f0-24, not connected, not favourite, paired, name: "iPad", recent access date: 2024-11-13 20:27:11 +0000
address: f8-ff-c2-2a-f1-c0, not connected, not favourite, paired, name: "user42's MacBook Pro", recent access date: 2024-11-13 20:27:11 +0000
mjfggc@CDOIT-P4VLY524QX raycast scripts % 

I made a quick and dirty regex script to try to get the address line out, but it doesn’t output the results I would like:

WIP Script
#!/bin/bash

input=$(blueutil --paired)
mod_input=$(echo "$input" | sed -E 's/\S{17}/$0\n/g;t')
echo "$mod_input"

If anyone has a decent solution, I would be ever grateful!

#!/bin/bash

input=$(blueutil --paired)
mod_input=$(echo "$input" | awk -F "[, ]+" '/address/{print $2}')
echo "$mod_input"

seems to be my fix