----------------------------------------------------------------------------------
@MSGID:
<ed97fde3-8593-4d1a-938d-80b79bfe9810n@googlegroups.com> 6ff0b09b
@REPLY:
<2eceb154-cc94-46a3-a897-825f885316f5n@googlegroups.com> 8586fb81
@REPLYADDR hongy...@gmail.com
<hongyi.zhao@gmail.com>
@REPLYTO 2:5075/128 hongy...@gmail.com
@CHRS: CP866 2
@RFC: 1 0
@RFC-References:
<f1c33e51-6c3b-4e7a-ab15-fd694fdee755n@googlegroups.com> <874jjqk812.fsf@nosuchdomain.example.com>
<2eceb154-cc94-46a3-a897-825f885316f5n@googlegroups.com>
@RFC-Message-ID:
<ed97fde3-8593-4d1a-938d-80b79bfe9810n@googlegroups.com>
@TZUTC: -0700
@PID: G2/1.0
@TID: FIDOGATE-5.12-ge4e8b94
On Wednesday, September 20, 2023 at 7:27:12 AM UTC+8,
hongy...@gmail.com wrote:
> On Tuesday, September 19, 2023 at 2:10:42 PM UTC+8, Keith Thompson wrote:
> > "
hongy...@gmail.com" <
hongy...@gmail.com> writes:
> > > I noticed the following usage here [1]:
> > >
> > > sed -i `/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL` /etc/sudoers
> > > visudo -c
> > >
> > > But I`m puzzled by the `c` that appeared in the `/%sudo/c`
part of the sed command above. Any tips will be helpful.
> > >
> > > [1]
https://blog.51cto.com/u 4820306/5425575
> > The `c` command is a GNU extension. Type "info sed" for documentation,
> > or search online for GNU sed documentation if you don`t have it
> > installed locally.
> >
> > (Seriously, I wonder why checking the documentation wasn`t your first
> > thought before posting here.)
> See the following documentation on my machine and the corresponding tests:
>
> The OS and sed info:
>
> werner@X10DAi:~$ lsb release -a
> No LSB modules are available.
> Distributor ID: Ubuntu
> Description: Ubuntu 22.04.3 LTS
> Release: 22.04
> Codename: jammy
>
> werner@X10DAi:~$ sed --version | head -1
> sed (GNU sed) 4.8
>
>
> info sed:
>
> `c`
> `TEXT`
> Replace (change) lines with TEXT.
>
> `c TEXT`
> Replace (change) lines with TEXT (alternative syntax).
>
> man sed:
>
> c \\
>
> text Replace the selected lines with text, which has each embed-
> ded newline preceded by a backslash.
>
>
> Further tests based on the above documentation:
>
> werner@X10DAi:~$ sed -n `/foo/c bar` <<< foo
> bar
> werner@X10DAi:~$ sed -n `/foo/cbar` <<< foo
> bar
> werner@X10DAi:~$ sed -n `/foo/c\\ bar` <<< foo
> bar
> werner@X10DAi:~$ sed -n `/foo/c \\ bar` <<< foo
> bar
> werner@X10DAi:~$ sed -n `/foo/c \\
> > bar` <<< foo
> bar
> werner@X10DAi:~$ sed -n `/foo/c \\
> bar` <<< foo
> bar
And, I am still puzzled by the following result:
werner@X10DAi:~$ sed -n `/foo/c
\bar` <<< foo
bar
Why doesn`t it give `\bar`?
>
> Therefore, the explanation of the documentation is not very adequate.
>
> Zhao
> > --
> > Keith Thompson (The Other Keith)
Keith.S.T...@gmail.com
> > Will write code for food.
> > void Void(void) { Void(); } /* The recursive call of the void */
--- G2/1.0
* Origin: usenet.network (2:5075/128)
SEEN-BY: 5001/100 5005/49 5015/255 5019/40 5020/715
848 1042 4441 12000
SEEN-BY: 5030/49 1081 5075/128
@PATH: 5075/128 5020/1042 4441