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
"[email protected]" <[email protected]> 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.)
The 'c' command is a GNU extension.
(Seriously, I wonder why checking the documentation wasn't your first
thought before posting here.)
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.
On Tuesday, September 19, 2023 at 2:10:42 PM UTC+8, Keith Thompson wrote:
"[email protected]" <[email protected]> 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/5425575The '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' <<< foobar
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) [email protected]
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */
"[email protected]" <[email protected]> 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/5425575The '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.)
bar' <<< foobar
--
Keith Thompson (The_Other_Keith) [email protected]
Will write code for food.
void Void(void) { Void(); } /* The recursive call of the void */
On Tuesday, September 19, 2023 at 2:10:42 PM UTC+8, Keith Thompson wrote:[SNIP]
"[email protected]" <[email protected]> writes:
I noticed the following usage here [1]:The 'c' command is a GNU extension. Type "info sed" for documentation,
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
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:
Therefore, the explanation of the documentation is not very adequate.
| Sysop: | Keyop |
|---|---|
| Location: | Huddersfield, West Yorkshire, UK |
| Users: | 715 |
| Nodes: | 16 (2 / 14) |
| Uptime: | 156:08:57 |
| Calls: | 12,092 |
| Files: | 15,000 |
| Messages: | 6,517,729 |