我们希望匹配字符串DataGuardDatadgSpace&在花括号内找到hostgroups字符串&在与hostgroups匹配的行中用SERVER-NODE1-DATABASE替换字符串SERVER-DATABASE。它不应该影响与字符串或其余代码匹配的servicegroups行。
我想在文件中编辑此代码。我尝试过以下选项
var rotation = /* Your quaternion */;
var cameraOrtX = rotation * new Vector3 (1, 0, 0);
var cameraOrtY = rotation * new Vector3 (0, 1, 0);
var cameraOrtZ = rotation * new Vector3 (0, 0, 1);
var cameraOrtPX = Vector3.ProjectOnPlane(cameraOrtX, new Vector3(0, 1, 0));
var cameraOrtPY = Vector3.ProjectOnPlane(cameraOrtY, new Vector3(0, 1, 0));
var cameraOrtPZ = Vector3.ProjectOnPlane(cameraOrtZ, new Vector3(0, 1, 0));
var centroid = (cameraOrtPX + cameraOrtPY + cameraOrtPZ) / 3.0f;
但它不适用于文件
define service { use generic-pasv-svc name SERVER-DATABASE-ArchdgSpace service_description DataGuardArchdgSpace hostgroups SERVER-DATABASE,xDB servicegroups PASV,SERVER-stack,SERVER-DATABASE max_check_attempts 3 check_command check_dummy!2!"Passive check is stale" contact_groups po check_freshness 1 freshness_threshold 180 register 1 } define service { use generic-pasv-svc name SERVER-DATABASE-DatadgSpace service_description DataGuardDatadgSpace servicegroups PASV,SERVER-stack,SERVER-DATABASE max_check_attempts 3 check_command check_dummy!2!"Passive check is stale" contact_groups po hostgroups SERVER-DATABASE,xDB check_freshness 1 freshness_threshold 180 register 1 } define service{ use generic-pasv-svc name ORA_DATABASE_HangDetect_DefunctProcess service_description ORA_HangDetect_DefunctProcess hostgroups SERVER-DATABASE servicegroups PASV check_command check_dummy!3!"Passive service check is stale, check the Ora HangDetect Script is running or not" freshness_threshold 600 contact_groups po max_check_attempts 2 normal_check_interval 5 retry_check_interval 1 register 1 }
答案 0 :(得分:3)
我认为您的示例代码中的主机组值应为SERVER-DATABASE
而不是SERVER--DATABASE
。如果是这样,你可以试试这个sed:
sed '/{/{:a;N;/}/!ba;/DataGuardDatadgSpace/s/\(.*hostgroups[[:space:]]*\)SERVER-DATABASE/\1SERVER-NODE1-DATABASE/;}' file
{
和}
之间的所有行都合并在模式空间中。如果在阻止中找到DataGuardDatadgSpace
,则SERVER-DATABASE
中的hostgroups
值将替换为SERVER- NODE1-DATABASE
。
添加-i
标志以编辑文件:
sed -i '/{/{:a;N;/}/!ba;/DataGuardDatadgSpace/s/\(.*hostgroups[[:space:]]*\)SERVER-DATABASE/\1SERVER-NODE1-DATABASE/;}' file