Nп/п : 84 из 100
 От   : hongy...@gmail.com                  2:5075/128        19 сен 23 16:27:08
 К    : Keith Thompson                                        19 сен 23 02:31:02
 Тема : Re: sed -i `/%sudo/c %sudo ALL=(ALL:ALL) NOPASSWD:ALL` /etc/sudoers
----------------------------------------------------------------------------------
                                                                                 
@MSGID:
<2eceb154-cc94-46a3-a897-825f885316f5n@googlegroups.com> 8586fb81
@REPLY: <874jjqk812.fsf@nosuchdomain.example.com>
499e16ac
@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>
@RFC-Message-ID:
<2eceb154-cc94-46a3-a897-825f885316f5n@googlegroups.com>
@TZUTC: -0700
@PID: G2/1.0
@TID: FIDOGATE-5.12-ge4e8b94
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 */
--- 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



   GoldED+ VK   │                                                 │   09:55:30    
                                                                                
В этой области больше нет сообщений.

Остаться здесь
Перейти к списку сообщений
Перейти к списку эх