Linux:利用 grep 取得 UUID
![圖片](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg-io2Nj46fipOYaW4Qb1zCoLuVXnnukgCGQ8rkF0AKJCM2ZdGPZpFT1BRkMkITBqAWs5nwJUaIQHvoyM77Di5aSv1O2-vlhUIuBKaQf6wXZQ1rosd5m487K4WRskr4SiFuKzV3XNf4x4r0/s1600/uuid.jpg)
有時在處理 linux 字串時我們會需要取得特定的 uuid, 此時 linux 指令中的 grep 就非常好用。 圖片來源:http://itunes.apple.com/gb/app/udid-pro-unique-device-identifier/id385539780?mt=8 以下舉個簡單的例子: # 假設想要取得 blkid 回傳回來的 uuid $ blkid /dev/root /dev/root: UUID="36215097-d2db-4882-ae1b-52ca5ef0b4ee" TYPE="ext3" # 利用 grep -o 取得特定格式的字串 $ blkid /dev/root | grep -o '[0-9a-fA-F]\{8\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{4\}-[0-9a-fA-F]\{12\}' 關鍵字:linux, grep, uuid, 怎麼取得, 抓, 參考資料: How to grep a UUID