Re: POSIX compliant sed making newline character

2020-08-22 Thread john doe
On 8/22/2020 6:33 PM, Andrei POPESCU wrote: On Vi, 21 aug 20, 21:06:05, john doe wrote: When I can not get the command I want, I break it down to the simplest command as possible then I build from there to the command I realy want. Have you considered that solution(s) found might not be usabl

Re: POSIX compliant sed making newline character

2020-08-22 Thread Andrei POPESCU
On Vi, 21 aug 20, 21:06:05, john doe wrote: > > When I can not get the command I want, I break it down to the simplest > command as possible then I build from there to the command I realy want. Have you considered that solution(s) found might not be usable in the bigger context, basically wastin

Re: POSIX compliant sed making newline character

2020-08-21 Thread john doe
On 8/21/2020 9:00 PM, Greg Wooledge wrote: On Fri, Aug 21, 2020 at 08:51:44PM +0200, john doe wrote: Okay, it uses the same syntax as for a subshell '$()'. No, one of them is $'' and the other is $(). They have nothing in common. One of them is a form of quoting. It acts just like '' except

Re: POSIX compliant sed making newline character

2020-08-21 Thread Greg Wooledge
On Fri, Aug 21, 2020 at 08:51:44PM +0200, john doe wrote: > Okay, it uses the same syntax as for a subshell '$()'. No, one of them is $'' and the other is $(). They have nothing in common. One of them is a form of quoting. It acts just like '' except that it performs various backslash expansion

Re: POSIX compliant sed making newline character

2020-08-21 Thread john doe
On 8/21/2020 8:37 PM, Greg Wooledge wrote: On Fri, Aug 21, 2020 at 02:35:35PM -0400, Greg Wooledge wrote: No. Use $'...' instead of '...'. sed '/line1/{N;N;a line-to-add\n}' input-file Crap. Of course I meant to write sed $'/line1/{N;N;a line-to-add\n}' input-file Okay, it uses the same

Re: POSIX compliant sed making newline character

2020-08-21 Thread Greg Wooledge
On Fri, Aug 21, 2020 at 02:35:35PM -0400, Greg Wooledge wrote: > No. Use $'...' instead of '...'. > > sed '/line1/{N;N;a line-to-add\n}' input-file Crap. Of course I meant to write sed $'/line1/{N;N;a line-to-add\n}' input-file

Re: POSIX compliant sed making newline character

2020-08-21 Thread Greg Wooledge
On Fri, Aug 21, 2020 at 08:09:26PM +0200, john doe wrote: > On 8/21/2020 7:51 PM, Greg Wooledge wrote: > > 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$'\

Re: POSIX compliant sed making newline character

2020-08-21 Thread john doe
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 th

Re: POSIX compliant sed making newline character

2020-08-21 Thread Greg Wooledge
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

POSIX compliant sed making newline character

2020-08-21 Thread john doe
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 `{' 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. What am I miss