-1
嗨我需要編輯一些文件,但我不想手動執行,我知道使用sed命令我可以使用命令行編輯文件,但在這種情況下,我不知道如何匹配編輯的模式。比如我有這個文件:bash替換文件中的多行文本,模式爲
(
AMI1
{
type patch; // <- relpace patch by cyclicAMI;
nFaces 1350;
startFace 2433406;
}
inlet
{
type patch;
nFaces 1125;
startFace 2434756;
}
outlet
{
type patch;
nFaces 1125;
startFace 2435881;
}
AMI2
{
type patch; // <- relpace patch by cyclicAMI;
nFaces 2850;
startFace 2440606;
}
)
我想編輯ONLY的AMI鍵看起來像這樣:
(
AMI1
{
type cyclicAMI; // <-- Replaced
inGroups 1(cyclicAMI); // <-- Add
nFaces 1350;
startFace 2433406;
matchTolerance 0.0001; // <-- Add
transform noOrdering; // <-- Add
neighbourPatch AMI2; // <-- Add AMI2 in AMI1
}
inlet
{
type patch;
nFaces 1125;
startFace 2434756;
}
outlet
{
type patch;
nFaces 1125;
startFace 2435881;
}
AMI2
{
type cyclicAMI; // <-- Replaced
inGroups 1(cyclicAMI); // <-- Add
nFaces 2850;
startFace 2440606;
matchTolerance 0.0001; // <-- Add
transform noOrdering; // <-- Add
neighbourPatch AMI1; // <-- Add AMI1 in AMI2
}
)
感謝您的回覆,但結果在'inlet'和'outlet'關鍵和最後括號右括號,缺少 – efirvida
@efirvida糟糕!固定。 – hidefromkgb
非常感謝,刪除最後一個空行是我的錯誤。謝謝!!,現在一切正常 – efirvida