Quantcast
Channel: linuxadmin: Expanding Linux SysAdmin knowledge
Viewing all articles
Browse latest Browse all 17905

Finding and Replacing UUIDs

$
0
0

I have 4 project files with a bunch of UUID's in them and I want to replace just one of them. Right now I'm using grep to find the word "ProductName" and then grabbing the line below it which has the UUID I want to change.

grep -A1 'ProductName' solution-win64.vdproj 

Returns

solution-win64.vdproj: "ProductName" = "8:Demo Product" solution-win64.vdproj- "ProductCode" = "8:{51A1D41B-BCCF-4D98-A96A-A55E9B88DA1B}" 

Now I want to grab just the ProductCode and replace the UUID so I figured sed would be the tool for this:

sed -i "s/[0-9A-F]\{8\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{4\}-[0-9A-F]\{12\}/`uuidgen | tr '[:lower:]' '[:upper:]'`/g" 

The problem I'm facing is I'm not sure how to pass the grep result and file over to sed so that it can generate the new UUID and replace / update the file. Hopefully I worded that clearly enough. I'm pretty certain I need to use xargs but not entirely sure on the syntaxs. Any help would be much appreciated!

submitted by Twi7ch
[link][2 comments]

Viewing all articles
Browse latest Browse all 17905

Trending Articles