0

So I'm currently trying to make a script for gptfdisk and I need to get the "Partition unique GUID". This is the output I get:

Partition GUID code: 48465300-0000-11AA-AA11-00306543ECAC (Apple HFS/HFS+)
Partition unique GUID: 677EDC3D-8AB1-458F-B849-F8B609339391
First sector: 352676 (at 1.3 GiB)
Last sector: 3899397 (at 14.9 GiB)
Partition size: 3546722 sectors (13.5 GiB)
Attribute flags: 0003000000000000
Partition name: 'Data'

In the end I want to have just the

677EDC3D-8AB1-458F-B849-F8B609339391

How would I accomplish this?

Jahid
  • 21,542
  • 10
  • 90
  • 108

3 Answers3

1

This will do :

sed -n '/unique GUID/{s/.* GUID: //p}' your_file

or if you wish to pipe some output do :

command | sed -n '/unique GUID/{s/.* GUID: //p}'
sjsam
  • 21,411
  • 5
  • 55
  • 102
0

grep wih Perl regex:

grep -oP '(?<=unique GUID: ).*' file
677EDC3D-8AB1-458F-B849-F8B609339391

Or using two grep operation:

grep 'unique GUID:' file | grep -o '[^[:blank:]]*$'
677EDC3D-8AB1-458F-B849-F8B609339391
Jahid
  • 21,542
  • 10
  • 90
  • 108
0

grep with awk -

cat file | grep 'Partition unique GUID' | awk -F: '{print $2}'

avivb
  • 187
  • 11