I'm looking forward to get a string from an cmd output (ID of tmutil destinationinfo).
I have tested this regex with https://regex101.com/r/aI3yH2/1:
/^.*?Name.+?backup02\nKind.+?\nID?\s+:\s([A-Z0-9\-]+)/s
Looks like it's working, I'm searching for backup01, backup02, ...
But how can I grab the ID to a variable within a shell script?
Output is like this:
====================================================
Name : backup02
Kind : Local
Mount Point : /Volumes/ext_backup01_02
ID : BC51C9FA-DE8A-4BA3-B23E-AEC10E9E9F69
> ==================================================
Name : backup01
Kind : Network
URL : afp://[email protected]/backup01
Mount Point : /Volumes/backup01
ID : 009B3736-61C5-4996-B9BC-A5230BED7961
====================================================
Name : backup03
Kind : Network
URL : afp://[email protected]/backup03
Mount Point : /Volumes/backup01
ID : 1E9A3734-33D6-1316-C9B4-B143DA35D9F2
I really don't know how to handle this. Sample code 100% not working:
#!/bin/bash
ID=$(tmutil destinationinfo | sed -E '/^.*?Name.+?backup02\nKind.+?\nID?\s+:\s([A-Z0-9\-]+)/s')
echo $ID
Thanks!