hi all
I have the following file: (example.txt showing down)
I need to edit the file , the main issue is to append text between two known lines in the file
first_line=")"
second_line="NIC Hr_Nic ("
For example
Need to add the following:
haattr -add RVG StorageRVG -string
haattr -add RVG StorageDG -string
haattr -add RVG StorageHostIds -string
haattr -delete RVG Primary
haattr -delete RVG SRL
haattr -delete RVG RLinks
Between
The first match line ")"
And the
second match line "NIC Hr_Nic ("
As described in example.txt file
How to do this by sed ... (If its difficult by sed it can also possible with perl)
remark (sed need to get two arguments the first argument is the first match line (first_line arg) the second argument is the second match line (second_line arg)
example.txt file:
group Hr_Grp (
SystemList = { london1 = 0, london2 = 1 }
AutoStartList = { london1, london2 }
)
NIC Hr_Nic (
Device = qfe0
)
IP Hr_Ip(
Device = qfe0
Address = "1.1.1.1" // Virtual IP
)
DiskGroup Hr_Dg(
DiskGroup = hrdg
)
RVG Hr_Rvg (
RVG = hr_rvg
DiskGroup = hrdg
)
Hr_Rvg requires Hr_Dg
Hr_Rvg requires Hr_Ip
Hr_Ip requires Hr_Nic
Example of the file after sed edit:
group Hr_Grp (
SystemList = { london1 = 0, london2 = 1 }
AutoStartList = { london1, london2 }
)
haattr -add RVG StorageRVG -string
haattr -add RVG StorageDG -string
haattr -add RVG StorageHostIds -string
haattr -delete RVG Primary
haattr -delete RVG SRL
haattr -delete RVG RLinks
NIC Hr_Nic (
Device = qfe0
)
IP Hr_Ip(
Device = qfe0
Address = "1.1.1.1" // Virtual IP
)
DiskGroup Hr_Dg(
DiskGroup = hrdg
)
RVG Hr_Rvg (
RVG = hr_rvg
DiskGroup = hrdg
)
Hr_Rvg requires Hr_Dg
Hr_Rvg requires Hr_Ip
Hr_Ip requires Hr_Nic