Discussion:
replace block of text
swimlappy
2008-06-06 13:51:58 UTC
Permalink
Hello,

I am trying to use the example in section 4.23.3 of the Sed FAQ to
replace a block of text with another block of text. I keep getting
the following error

sed: file blockrep.sed line 18: unterminated `s' command

I am running this on a RedHat Enterprise Linux 4 update 6 box with the
lastest version of everything. Can someone offer some help as to why
I'm getting this error? I'm not all that versed in Sed, so I figured
I would be able to use the example already written pretty easily. Thanks

jay
Almir Karic
2008-06-08 14:07:46 UTC
Permalink
you can't really expect to get any help without showing what excatly
are you doing :-)

anyway, here is an example of what you seem to be after:

***@laptop:~$ seq 9 | sed -f block.sed
1
2
serveral
lines
long
text
8
9
***@laptop:~$ cat block.sed
/3/,/7/ {
/7/ a\
serveral\
lines\
long\
text
d
}
Post by swimlappy
Hello,
I am trying to use the example in section 4.23.3 of the Sed FAQ to
replace a block of text with another block of text. I keep getting
the following error
sed: file blockrep.sed line 18: unterminated `s' command
I am running this on a RedHat Enterprise Linux 4 update 6 box with the
lastest version of everything. Can someone offer some help as to why
I'm getting this error? I'm not all that versed in Sed, so I figured
I would be able to use the example already written pretty easily. Thanks
jay
------------------------------------
--
Yahoo! Groups Links
--
For far too long, power has been concentrated in the hands of "root"
and his "wheel" oligarchy. We have instituted a dictatorship of the
users. All system administration functions will be handled by the
People's Committee for Democratically Organizing the System (PC-DOS).
Eric Pement
2008-06-08 22:41:52 UTC
Permalink
Post by swimlappy
I am trying to use the example in section 4.23.3 of the Sed FAQ to
replace a block of text with another block of text. I keep getting
the following error
sed: file blockrep.sed line 18: unterminated `s' command
I am running this on a RedHat Enterprise Linux 4 update 6 box with the
lastest version of everything. Can someone offer some help as to why
I'm getting this error?
Do this:

sed -n 18p blockrep.sed

That will display line #18, which is where the error occurs.

You should have an "s" (substitution) command there. The "s" command
should have 3 delimiters after it, like:

s/find/replace/g; # 3 slashes

s,find,replace,g; # 3 commas

***@find@replace@; # 3 "at" symbols

Your script is missing a delimiter for the "s" command. Let us know
if you need any additional help.
--
Eric Pement - ***@northpark.edu
persson
2008-06-09 09:33:29 UTC
Permalink
Post by swimlappy
Hello,
I am trying to use the example in section 4.23.3 of the Sed FAQ to
replace a block of text with another block of text. I keep getting
the following error
sed: file blockrep.sed line 18: unterminated `s' command
It's difficult to guess given that you don't show your script, but you
probably have a substitution command with an embedded newline somewhere,
like eg

s/foo/some
text/

you can do that, but then you have to write that this way:

s/foo/some\
text

or, if you have GNU sed, you can also do

s/foo/some\ntext/
higuita7
2011-11-30 15:54:15 UTC
Permalink
This is probably very old, but searching the net i didnt found the solution, but many people with the same problem... so lets document the solution :)
Post by swimlappy
I am trying to use the example in section 4.23.3 of the Sed FAQ to
replace a block of text with another block of text. I keep getting
the following error
sed: file blockrep.sed line 18: unterminated `s' command
the example blockreq.sed is wrong (or at least outdated to gnu sed)...

just edit the file and move the second [ next to the ] on line 18:

s,[/\[.*],\\&,g -> s,[/\.*[],\\&,g

the [ character inside a [] group must be next to the close tag ]
the ] is the opposite, must be near the open tag [

good luck
higuita

Continue reading on narkive:
Loading...