我对 aws cloudformation 非常陌生,我尝试在私有 VPC 中启动安装了 Neo4j 的 EC2,我发现有人已经使用 Neo4j 创建了一个 cloudformation 模板,但该实例适用于公共 VPC,所以我有修改了模板以适合我的目的,但是当我启动它时遇到了这个问题:“找不到资源的属性 publicip”
以下是脚本的一部分(没有 neo4j bash 脚本和 EBS 卷设置):
"Mappings" : {
"AWSRegionArch2AMI" : {
"eu-west-1" : { "64" : "ami-58d7e821" }
}
},
"Parameters": {
"InstanceType" : {
"Description" : "EC2 instance type",
"Type" : "String",
"Default" : "m5.large",
"ConstraintDescription" : "Must be a valid EC2 instance type."
},
"SSHKeyName": {
"Description": "Name of the SSH key that you will use to access the server (must be …
Run Code Online (Sandbox Code Playgroud) 我是 powershell 的新手,对 .net 没有经验。我有一个脚本,用于
(get-content | select-string -pattern -allmatches).matches | measure-object
查找和计算文件中的字符数。如果文件只包含少于 10k 行,我的脚本将正常工作。否则对于大文件,RAM 将达到 100%,然后 Powershell 将显示(无响应)
我做了一些研究,发现 system.io.streamreader 可以工作,我在 Stackoverflow 中阅读了几个问题,要查找和匹配文件中的字符或单词,您只需执行以下操作:
$file = get-item '<file path>'
$reader = New-Object -TypeName System.IO.StreamReader -ArgumentList $file
[int]$line = 0
while ( $read = $reader.ReadLine() ) {
if ( $read -match '<charcter>' ) {
$line++
}
}
Run Code Online (Sandbox Code Playgroud)
但这只是返回包含字符的行数,而不是文件中的字符数。那么我如何使用(select-string -inputobject -pattern -allmatches).matches | measure-object
流阅读器呢?