Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

If the code and the comments disagree, then both are probably wrong. -- Norm Schryer


devel / comp.unix.shell / sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers

SubjectAuthor
* sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoershongy...@gmail.com
`* Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoersKeith Thompson
 +- Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoersChris Elvidge
 +* Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoersAndy Walker
 |`- Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoersJim
 `* Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoershongy...@gmail.com
  +- Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoershongy...@gmail.com
  `- Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoersKeith Thompson

1
sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers

<f1c33e51-6c3b-4e7a-ab15-fd694fdee755n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6652&group=comp.unix.shell#6652

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ad4:4f51:0:b0:656:27bf:519c with SMTP id eu17-20020ad44f51000000b0065627bf519cmr225810qvb.10.1695099855375;
Mon, 18 Sep 2023 22:04:15 -0700 (PDT)
X-Received: by 2002:a9d:6d92:0:b0:6c0:a3e0:f9e3 with SMTP id
x18-20020a9d6d92000000b006c0a3e0f9e3mr3500289otp.5.1695099855121; Mon, 18 Sep
2023 22:04:15 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Mon, 18 Sep 2023 22:04:14 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=208.86.32.27; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 208.86.32.27
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <f1c33e51-6c3b-4e7a-ab15-fd694fdee755n@googlegroups.com>
Subject: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Tue, 19 Sep 2023 05:04:15 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 1325
 by: hongy...@gmail.com - Tue, 19 Sep 2023 05:04 UTC

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

Regards,
Zhao

Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers

<874jjqk812.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6653&group=comp.unix.shell#6653

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers
Date: Mon, 18 Sep 2023 23:10:33 -0700
Organization: None to speak of
Lines: 21
Message-ID: <874jjqk812.fsf@nosuchdomain.example.com>
References: <f1c33e51-6c3b-4e7a-ab15-fd694fdee755n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain
Injection-Info: dont-email.me; posting-host="db989aa286e51ccd0458447dc5251e4d";
logging-data="2346988"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18q5BoYx3CFXX0LfOq1qUcp"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:nPxho+79nX3Pt5CDW5FBjiNDfOM=
sha1:O5LBR2RWro71X4xOR6o5sSAq25s=
 by: Keith Thompson - Tue, 19 Sep 2023 06:10 UTC

"hongy...@gmail.com" <hongyi.zhao@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.)

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers

<uebsjg$2a1j4$2@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6654&group=comp.unix.shell#6654

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!news.hispagatos.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: chr...@mshome.net (Chris Elvidge)
Newsgroups: comp.unix.shell
Subject: Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers
Date: Tue, 19 Sep 2023 11:19:27 +0100
Organization: A noiseless patient Spider
Lines: 25
Message-ID: <uebsjg$2a1j4$2@dont-email.me>
References: <f1c33e51-6c3b-4e7a-ab15-fd694fdee755n@googlegroups.com>
<874jjqk812.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 10:19:28 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="7d8ee0ad43f69941e61be579c99de06e";
logging-data="2426468"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18khex/0eS6pIa/+QZG+QaomUnMkNoAG3k="
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101
Thunderbird/52.2.1 Lightning/5.4
Cancel-Lock: sha1:6kY0JExgTdaY6dL253Vnwylc3WA=
In-Reply-To: <874jjqk812.fsf@nosuchdomain.example.com>
Content-Language: en-GB
 by: Chris Elvidge - Tue, 19 Sep 2023 10:19 UTC

On 19/09/2023 07:10, Keith Thompson wrote:
> "hongy...@gmail.com" <hongyi.zhao@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.)
>

Seriously, you're asking hongyi to check the documentation?

--
Chris Elvidge, England
I WILL NOT USE ABBREV.

Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers

<uebt7o$2a6oh$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6655&group=comp.unix.shell#6655

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: anw...@cuboid.co.uk (Andy Walker)
Newsgroups: comp.unix.shell
Subject: Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers
Date: Tue, 19 Sep 2023 11:30:16 +0100
Organization: Not very much
Lines: 32
Message-ID: <uebt7o$2a6oh$1@dont-email.me>
References: <f1c33e51-6c3b-4e7a-ab15-fd694fdee755n@googlegroups.com>
<874jjqk812.fsf@nosuchdomain.example.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
Injection-Date: Tue, 19 Sep 2023 10:30:16 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="6d175ada008ecfbf6a48f8310d971e5c";
logging-data="2431761"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19ztqWIi/hWJc+Hlq/nPolU"
User-Agent: Mozilla/5.0 (X11; Linux i686; rv:102.0) Gecko/20100101
Thunderbird/102.11.0
Cancel-Lock: sha1:nGItmeMU+Tb0T43WQ3YqwtjO/Qw=
Content-Language: en-GB
In-Reply-To: <874jjqk812.fsf@nosuchdomain.example.com>
 by: Andy Walker - Tue, 19 Sep 2023 10:30 UTC

On 19/09/2023 07:10, Keith Thompson wrote:
[Sed:]
> The 'c' command is a GNU extension.

The "c" /command/ was "original", and is in 7th Edition Unix.
But originally it had to be followed /immediately/ by a backslash,
with the replacement text on the following line(s). On my current
[Linux] machine, "man sed" shows optional space(s) between "c" and
the backslash [which is presumably the GNU extension, as it's an
obvious change to make on a re-write]. But it doesn't show the extra
[also obvious] possibility of the replacement text on the same line,
for which, as you suggest, you need "info sed".

Personally, I prefer "man" to "info", if available, as the
output is formatted nicely, so it's understandable that the extra
extension should be overlooked. OTOH, once spaces are allowed, it's
harder to exclude the same-line extensions to "a", "c" and "i" than
to allow them, so perhaps the documentation should emphasise the
same-line version and then point out the usefulness of backslashes.

[To Zhao:]
> (Seriously, I wonder why checking the documentation wasn't your first
> thought before posting here.)

Perhaps he enjoys getting a rise out of people who wonder why
he prefers asking here to checking elsewhere? It's not as though this
is the first example of its type over the past decade and more.

--
Andy Walker, Nottingham.
Andy's music pages: www.cuboid.me.uk/andy/Music
Composer of the day: www.cuboid.me.uk/andy/Music/Composers/Praetorius

Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers

<uec95t$2c8ul$1@dont-email.me>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6656&group=comp.unix.shell#6656

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: jim.be...@verizon.net (Jim)
Newsgroups: comp.unix.shell
Subject: Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers
Date: Tue, 19 Sep 2023 13:54:05 -0000 (UTC)
Organization: A noiseless patient Spider
Lines: 30
Message-ID: <uec95t$2c8ul$1@dont-email.me>
References: <f1c33e51-6c3b-4e7a-ab15-fd694fdee755n@googlegroups.com>
<874jjqk812.fsf@nosuchdomain.example.com> <uebt7o$2a6oh$1@dont-email.me>
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
Injection-Date: Tue, 19 Sep 2023 13:54:05 -0000 (UTC)
Injection-Info: dont-email.me; posting-host="d2a83e06d712cfd94f3ede2e481f35b3";
logging-data="2499541"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+fPS+Ik4Al3AP0iyPphLRP"
User-Agent: Pan/0.149 (Bellevue; 4c157ba git@gitlab.gnome.org:GNOME/pan.git)
Cancel-Lock: sha1:ZsaO1pUqdHlAHiLPqmNpjsg95zQ=
 by: Jim - Tue, 19 Sep 2023 13:54 UTC

On Tue, 19 Sep 2023 11:30:16 +0100, Andy Walker wrote:

> On 19/09/2023 07:10, Keith Thompson wrote:

> [To Zhao:]
>> (Seriously, I wonder why checking the documentation wasn't your first
>> thought before posting here.)
>
> Perhaps he enjoys getting a rise out of people who wonder why
> he prefers asking here to checking elsewhere? It's not as though this
> is the first example of its type over the past decade and more.

Hongi's general knowledge of English in the subject area of concern
may not match your general knowledge of English in it.

What you find easy to understand or obvious from reading the man
and info texts may not be as easy or obvious for Hongi.

On an interactive forum, one can persist in trying to clarify
one's understanding.

Cheers!

jim b.

--
UNIX is not user-unfriendly, it merely
expects users to be computer friendly.

Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers

<2eceb154-cc94-46a3-a897-825f885316f5n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6657&group=comp.unix.shell#6657

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:ad4:57cd:0:b0:656:3463:4509 with SMTP id y13-20020ad457cd000000b0065634634509mr8240qvx.3.1695166029546;
Tue, 19 Sep 2023 16:27:09 -0700 (PDT)
X-Received: by 2002:a05:6830:1cb:b0:6b9:2c07:8849 with SMTP id
r11-20020a05683001cb00b006b92c078849mr413685ota.0.1695166029245; Tue, 19 Sep
2023 16:27:09 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 19 Sep 2023 16:27:08 -0700 (PDT)
In-Reply-To: <874jjqk812.fsf@nosuchdomain.example.com>
Injection-Info: google-groups.googlegroups.com; posting-host=208.86.32.27; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 208.86.32.27
References: <f1c33e51-6c3b-4e7a-ab15-fd694fdee755n@googlegroups.com> <874jjqk812.fsf@nosuchdomain.example.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <2eceb154-cc94-46a3-a897-825f885316f5n@googlegroups.com>
Subject: Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Tue, 19 Sep 2023 23:27:09 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3266
 by: hongy...@gmail.com - Tue, 19 Sep 2023 23:27 UTC

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

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 */

Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers

<ed97fde3-8593-4d1a-938d-80b79bfe9810n@googlegroups.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6658&group=comp.unix.shell#6658

  copy link   Newsgroups: comp.unix.shell
X-Received: by 2002:a05:620a:409:b0:76d:c77f:cf0b with SMTP id 9-20020a05620a040900b0076dc77fcf0bmr13311qkp.9.1695166644039;
Tue, 19 Sep 2023 16:37:24 -0700 (PDT)
X-Received: by 2002:a05:6870:5aae:b0:1c8:f237:303a with SMTP id
dt46-20020a0568705aae00b001c8f237303amr346227oab.5.1695166643612; Tue, 19 Sep
2023 16:37:23 -0700 (PDT)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.unix.shell
Date: Tue, 19 Sep 2023 16:37:23 -0700 (PDT)
In-Reply-To: <2eceb154-cc94-46a3-a897-825f885316f5n@googlegroups.com>
Injection-Info: google-groups.googlegroups.com; posting-host=208.86.32.27; posting-account=kF0ZaAoAAACPbiK5gldhAyX5qTd3krV2
NNTP-Posting-Host: 208.86.32.27
References: <f1c33e51-6c3b-4e7a-ab15-fd694fdee755n@googlegroups.com>
<874jjqk812.fsf@nosuchdomain.example.com> <2eceb154-cc94-46a3-a897-825f885316f5n@googlegroups.com>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ed97fde3-8593-4d1a-938d-80b79bfe9810n@googlegroups.com>
Subject: Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers
From: hongyi.z...@gmail.com (hongy...@gmail.com)
Injection-Date: Tue, 19 Sep 2023 23:37:24 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
X-Received-Bytes: 3823
 by: hongy...@gmail.com - Tue, 19 Sep 2023 23:37 UTC

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 */

Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers

<87cyyditjj.fsf@nosuchdomain.example.com>

  copy mid

https://www.novabbs.com/devel/article-flat.php?id=6659&group=comp.unix.shell#6659

  copy link   Newsgroups: comp.unix.shell
Path: i2pn2.org!i2pn.org!eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail
From: Keith.S....@gmail.com (Keith Thompson)
Newsgroups: comp.unix.shell
Subject: Re: sed -i '/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL' /etc/sudoers
Date: Tue, 19 Sep 2023 17:21:04 -0700
Organization: None to speak of
Lines: 47
Message-ID: <87cyyditjj.fsf@nosuchdomain.example.com>
References: <f1c33e51-6c3b-4e7a-ab15-fd694fdee755n@googlegroups.com>
<874jjqk812.fsf@nosuchdomain.example.com>
<2eceb154-cc94-46a3-a897-825f885316f5n@googlegroups.com>
MIME-Version: 1.0
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: 8bit
Injection-Info: dont-email.me; posting-host="c95a7bd4ec59e911bcb03685ef3cdd0a";
logging-data="2727484"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX19UDFGv6nL4lDYDF8CQyuSh"
User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.2 (gnu/linux)
Cancel-Lock: sha1:W9oaFJPakOI4/lssmUC6Ua77m5M=
sha1:HJQkHq7DJlW4E3eFwKYQ5KW2QUg=
 by: Keith Thompson - Wed, 20 Sep 2023 00:21 UTC

"hongy...@gmail.com" <hongyi.zhao@gmail.com> writes:
> 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:
[SNIP]
> Therefore, the explanation of the documentation is not very adequate.

I see that the explanation in `info sed` is clear enough to explain the
behavior of the sed command you showed in the parent article. (Each
line containing "%sudo" is replaced with the specified text. You could
use the 's' command to do the same thing, perhaps more clearly, since
the 'c' command is a bit obscure IMHO.)

(`man sed` is missing this information, but the "SEE ALSO" section
at the bottom says the man page is incomplete. This is usually
the case for GNU software.)

I'd just edit the file manually using `visudo`, but maybe you want to do
this on a lot of systems and want to automate it.

You might also consider first running the sed command on a copy of your
sudoers file so you don't risk breaking anything.

If you want to ask about something like this please (1) let us know that
you actually checked the documentation before posting (it was reasonable
to assume that you hadn't bothered) and (2) if you find the
documentation unclear, let us know what you find unclear about it.

--
Keith Thompson (The_Other_Keith) Keith.S.Thompson+u@gmail.com
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor