Results 1 to 2 of 2
Hi,
My goal is to delete all text between to points and then insert a newline between these two points using sed stream editor (I should mentioned these commands will ...
- 02-03-2009 #1Just Joined!
- Join Date
- Jul 2006
- Posts
- 6
Deleting text within a range with sed.
Hi,
My goal is to delete all text between to points and then insert a newline between these two points using sed stream editor (I should mentioned these commands will be executed from a sed script not directly on the command line).
Example: delete text between two points.
point A
line 1 <-- Delete
line2 <-- Delete
point B
results in:
point A
point B
Then: insert newline between these points .
point A
\n
point B
I have been using the following code, although the text is successfully deleted between the two points when it comes to the next command the insertion of the newline fails to happen as sed seems to not be able to match the regex:
# Removes unwanted text between to points in the file.
/point A/,/point B/{
/point A/b
/point B/b
d
}
# Inserts newline where text was removed from last command.
/point A/a\
\n
Thanks in advance for any help, advice or pointers.
- 02-05-2009 #2Linux User
- Join Date
- Jan 2007
- Location
- cleveland
- Posts
- 452
here's a way, using the marker "nnnn" supposed never to occur at the
beginning of a line:
sed '/Point A/ a\nnnn' <filename |sed 's/^nnnn/ /'the sun is new every day (heraclitus)


Reply With Quote