- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我有一个文件,其中包含大量出现的字符串 Guid="GUID HERE"
(其中 GUID HERE
在每次出现时都是唯一的 GUID),我想用新的唯一 GUID 替换每个现有的 GUID。
这是在 Windows 开发机器上,所以我可以用 uuidgen.exe
生成唯一的 GUID。 (每次运行时都会在 stdout 上生成一个 GUID)。我有 sed
和这样的可用(但没有 awk
很奇怪)。
我基本上是想弄清楚是否可以(如果可以,如何)使用命令行程序的输出作为 sed
中的替换文本。替换表达式,以便我可以以最少的努力进行此替换。我不需要使用 sed
-- 如果有其他方法可以做到,比如一些疯狂的 vim
-fu 或其他一些程序,它也可以工作——但我更喜欢使用最少的 *nix 程序集的解决方案,因为我不是真的在 *nix 机器上。
需要明确的是,如果我有这样的文件:
etc etc Guid="A" etc etc Guid="B"
etc etc Guid="C" etc etc Guid="D"
xargs
用于类似的事情,但它在我需要它运行的机器上也不可用。如果它真的是唯一的方法,我可以安装它,尽管我宁愿不)
最佳答案
我在 PowerShell 中重写了 C# 解决方案。我认为运行 powershell 脚本然后编译 C# exe 对您来说会更容易。
使用步骤:
## GuidSwap.ps1
##
## Reads a file, finds any GUIDs in the file, and swaps them for a NewGUID
##
$filename = "d:\test.txt"
$outputFilename = "d:\test_new.txt"
$text = [string]::join([environment]::newline, (get-content -path $filename))
$sbNew = new-object system.text.stringBuilder
$pattern = "[a-fA-F0-9]{8}-([a-fA-F0-9]{4}-){3}[a-fA-F0-9]{12}"
$lastStart = 0
$null = ([regex]::matches($text, $pattern) | %{
$sbNew.Append($text.Substring($lastStart, $_.Index - $lastStart))
$guid = [system.guid]::newguid()
$sbNew.Append($guid)
$lastStart = $_.Index + $_.Length
})
$null = $sbNew.Append($text.Substring($lastStart))
$sbNew.ToString() | out-file -encoding ASCII $outputFilename
Write-Output "Done"
关于shell - 从命令行用新的 GUID 替换文件中的所有 GUID,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2201740/
我有某些场景(例如,一个自定义类来保存 Sql 参数),其中可能需要也可能不需要变量。传统上,我一直将这些定义为 Guid? 类型,并在使用前使用 myGuid.HasValue 检查有效值。 当然在
在 rpc.h 中,GUID 结构声明如下: typedef struct _GUID { DWORD Data1; WORD Data2; WORD Data3; B
使用 Dynamics CRM 我试图创建一个实体的实例。我想手动设置 GUID,但如果我拥有作为 DynamicEntity 主键的属性,则会出现以下错误。 Service could not pr
我需要将 GUID PK 字段(长度 = 36)发送到只接受 20 个字符长的下游系统。在下游系统中增加字段的长度成本过高。如果我截断该字段,那么我将失去它的唯一性。 有什么方法可以在不丢失唯一性的情
我听说 melissa 蠕虫的创建者因生成的 GUID 可以链接回他使用的计算机的 MAC 地址而被定罪。 做到这一点有多难?除了 GUID,他们还需要哪些数据?喜欢 MAC 地址本身还是创建时间?
使用 GUID 作为文件名和 นด 上传的图像以避免重复有什么缺点吗? 最佳答案 您的文件名将是唯一的,真的。但是没有任何方法可以按任何顺序对它们进行排序。 您可以使用 Unix TimeStamp在
我正在做一些互操作,需要传递一些 GUID。有没有办法将 GUID 属性添加到枚举值,并且当它被编码时它具有适当的值? 基本上我正在尝试转换代码 #if !defined( STATIC_KSDATA
我有一个文件,其中包含大量出现的字符串 Guid="GUID HERE" (其中 GUID HERE 在每次出现时都是唯一的 GUID),我想用新的唯一 GUID 替换每个现有的 GUID。 这是在
我已经向我们的客户发送了 10000 封邮件,每封邮件都有一个格式的链接 http://example.com/LogIn?key={guid} 不幸的是guid我发送的是随机 guids(由 Gui
使用 Breeze,在创建实体时填充 GUID 键的最简单方法是什么? 最佳答案 我假设您的实体已配置为客户端负责为新实体设置 Guid 键。这是 Entity Framework 代码优先实体的 G
我看到这两个首字母缩略词被抛出,我想知道 GUID 和 UUID 之间是否有任何区别? 最佳答案 简单回答是:**没有区别,它们是同一个东西。 2020-08-20 更新 :虽然 GUID(由 Mic
我注意到有些人不打算使用通常的递增数字作为 ID,而是简单地生成 GUID。优点包括: 快速简单 无需跟踪以前的 ID 即使在机器之间互不了解的情况下也能保证唯一性 一些缺点是: 可能存在性能瓶颈 使
我是 C++/CLI 的新手,我正在尝试将 native C++ GUID 转换为我的 C++/CLI Guid^。尝试转换时: BlockInfo^ blockInfo = gcnew BlockI
这个问题在这里已经有了答案: 11 年前关闭。 Possible Duplicate: Is there any difference between a GUID and a UUID? GUID
我正在使用 Data::GUID生成 GUID。然而,每当我在同一个“ session ”中生成 GUID,即运行脚本时,唯一改变的数字是最前面的数字: 3BAF1240-0573-11E4-B31C
我有一个对象列表,它们具有 id 的 guid。我想使用这个对象列表中的 id 创建一个 guid,我可以使用它来确保列表没有改变。如果删除/添加了一个对象,则 guid 会有所不同。我想到的是使用哈
上下文:ASP.NET Web API v2 给定一个类似于这个的 URL: http://localhost/something?id=cbc66d32-ece8-400f-a574-e36b911
这是将 Guid 转换为 Guid 的惯用方法吗?? new Guid?(new Guid(myString)); 最佳答案 不,这是: Guid? foo = new Guid(myString);
我想从输入字符串生成一个 GUID。假设我从用户那里收到了 guid,它是 81a130d2-502f-4cf1-a376-63edeb000e9f 所以我可以这样做: Guid g = Guid.
为什么无参数 Guid 构造函数生成一个空 GUID,而不是像 Guid.NewGuid() 那样默认生成一个? 空 Guid 是否有特殊用途? 最佳答案 Why does the parameter
我是一名优秀的程序员,十分优秀!