SED question: Inserting a blank line - shell
This is a discussion on SED question: Inserting a blank line - shell ; I have a SED file that replaces a bunch of stuff. In one line I am trying to add a blank line in the target text file after the following word at the beginning of a line: "BY" My expression ...
![]() |
| | LinkBack | Thread Tools | Display Modes |
|
#1
| |||
| |||
| trying to add a blank line in the target text file after the following word at the beginning of a line: "BY" My expression is as follows: s/^BY*$/BY*$\ / When I run SED on the target text file I get the following error message: sed: 42: scripts/ppsedf: unterminated regular expression (my_sed executable file calls the my_sedf). What should I do? If it matters, I am on a system using Open BSD. Thanks, Deguza |
|
#2
| |||
| |||
|
At 2008-11-12 12:53PM, "Kompu Kid" wrote: > I have a SED file that replaces a bunch of stuff. In one line I am > trying to add a blank line in the target text file after the > following word at the beginning of a line: > > "BY" Instead of search and replace, try triggering an action when that pattern is seen: printf "%s\n" A B BY C D | sed '/^BY/a ' Or, using awk: printf "%s\n" A B BY C D | awk '1{print}/^BY/{print ""}' -- Glenn Jackman Write a wise saying and your name will live forever. -- Anonymous |
|
#3
| |||
| |||
|
2008-11-12, 18:23(+00), Glenn Jackman: > At 2008-11-12 12:53PM, "Kompu Kid" wrote: >> I have a SED file that replaces a bunch of stuff. In one line I am >> trying to add a blank line in the target text file after the >> following word at the beginning of a line: >> >> "BY" > > Instead of search and replace, try triggering an action when that > pattern is seen: > > printf "%s\n" A B BY C D | sed '/^BY/a > ' [...] or ... | sed '/^BY/G' -- Stéphane |
|
#4
| |||
| |||
|
On Nov 12, 9:53*am, Kompu Kid > I have a SED file that replaces a bunch of stuff. In one line I am > trying to add a blank line in the target text file after the > following word at the beginning of a line: > > "BY" > > My expression is as follows: > > s/^BY*$/BY*$\ > / > > When I run SED on the target text file I get the following error > message: > > sed: 42: scripts/ppsedf: unterminated regular expression > > (my_sed executable file calls the my_sedf). > > What should I do? > > If it matters, I am on a system using Open BSD. > > Thanks, > > Deguza Thanks for all those who answered. I inserted /^BY/G into my my_sedf file and it seems to do the trick. Deguza |
![]() |
« Previous Thread
|
Next Thread »
| Thread Tools | |
| Display Modes | |
| |
All times are GMT -4. The time now is 03:43 PM.




Linear Mode