I want to delete all the line between two patterns using basic awk or sed.
foo.txt
:
---------------------------------------------------------------------- Cap in MB
line 2
line 3
line 4
line 5
--------------------------------------------------- Cap in MB
---------------------------------------------------------------------- Cap in MB
line 2
line 3
line 4
line 5
--------------------------------------------------- Cap in MB
---------------------------------------------------------------------- Cap in MB
line 2
line 3
line 4
line 5
--------------------------------------------------- Cap in MB
---------------------------------------------------------------------- Cap in MB
line 2
line 3
line 4
line 5
---------------------------------------------------------------------- Cap in MB
line 2
line 3
line 4
line 5
output.txt
:
---------------------------------------------------------------------- Cap in MB
Deleted up to this point
---------------------------------------------------------------------- Cap in MB
Deleted up to this point
---------------------------------------------------------------------- Cap in MB
Deleted up to this point
---------------------------------------------------------------------- Cap in MB
line 2
line 3
line 4
line 5
---------------------------------------------------------------------- Cap in MB
line 2
line 3
line 4
line 5
I am using solaris 5.10, basic awk and sed only. The number of lines between 2 patterns may vary.
Notice that the second string must be replaced but not the first string. Notice the difference between 2 patterns is the number of dashes. What you see in foo.txt
is exactly what I have my real file.