[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: POSIX compliant sed making newline character



On 8/21/2020 7:51 PM, Greg Wooledge wrote:
On Fri, Aug 21, 2020 at 07:49:07PM +0200, john doe wrote:
Hello all,

I'm trying to use the command provided at (1):

$ sed '/pattern{N;N;a try\d10}' input-file
sed: -e expression #1, char 0: unmatched `{'

Are you missing a second / character after the pattern?

Why are you obfuscating the command?  Why not SHOW the actual command?


Yes, I'm missing a '/'.

the command is:

$ sed '/line1/{N;N;a line-to-add}' input-file

As I understanded, I should make a newline before the right brace.
I thought that '\d10' should do it but as shown above it does not.

I have no idea how you came up with that.

If you're doing this from bash, you could use bash's special $'...'
quoting to pass a newline encoded as \n .


So something like the following:

$ sed '/line1/{N;N;a line-to-add$'\n'}' input-file

Otherwise, put an ACTUAL newline inside the quotes.  You know, by
pressing the Enter key.  That's portable to every sh family shell.


Actually, I do not know, that is why  I'm  asking in here! :)

--
John Doe


Reply to: