Search code examples
bashshellsedgrepcut

Get the Vaule from shell output


I have below output from a shell command . How can i get only the "UUID" value which is "72b11d-c808-455d-b684-fdc77cb596" . Can some one help me ?

/dev/sdc1: UUID="72b11d-c808-455d-b684-fdc77cb596" TYPE="ext4" PARTUUID="ac212435-01"

Desired output "72b11d-c808-455d-b684-fdc77cb596"


Solution

  • $ echo '/dev/sdc1: UUID="72b11d-c808-455d-b684-fdc77cb596" TYPE="ext4" PARTUUID="ac212435-01"' | cut -d= -f2 | cut -d' ' -f1
    "72b11d-c808-455d-b684-fdc77cb596"