How to grep 7 lines after match and replace text?
Clash Royale CLAN TAG#URR8PPP
up vote
3
down vote
favorite
I'm trying grep 7 lines after match and replace a context in those 7 lines and save it in the same file.
For Example:
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
i would like to replace the value of MaxRequestsPerChild
with 5000
.
I have tried with:
grep "IfModule prefork.c" httpd.conf -A7 | /bin/sed -nE "/bMaxRequestsPerChildb/ s/[0-9]+/50/"
But no luck.
linux shell-script sed grep
 |Â
show 8 more comments
up vote
3
down vote
favorite
I'm trying grep 7 lines after match and replace a context in those 7 lines and save it in the same file.
For Example:
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
i would like to replace the value of MaxRequestsPerChild
with 5000
.
I have tried with:
grep "IfModule prefork.c" httpd.conf -A7 | /bin/sed -nE "/bMaxRequestsPerChildb/ s/[0-9]+/50/"
But no luck.
linux shell-script sed grep
why not just grep for the string you're looking for in the first place?
â imabug
Jun 21 at 9:25
1
Sorry if I'm a bit daft, but why not just change the line in an editor?
â Kusalananda
Jun 21 at 9:25
@imabug there are other modules having the same pattern.
â nkmox k
Jun 21 at 9:26
2
there is several problem here, first, you want to edit a file and you do not provide sed with a file name but with stdin. So sed will never work, I suggest you write a script that get line number with grep and then sed inline at the properline number. I will not help you make this logic a oneliner
â Kiwy
Jun 21 at 9:28
2
@nkmoxk You're administrating 73 machines. Are you thinking you would run this over SSH in a loop? Have you considered Ansible?
â Kusalananda
Jun 21 at 9:30
 |Â
show 8 more comments
up vote
3
down vote
favorite
up vote
3
down vote
favorite
I'm trying grep 7 lines after match and replace a context in those 7 lines and save it in the same file.
For Example:
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
i would like to replace the value of MaxRequestsPerChild
with 5000
.
I have tried with:
grep "IfModule prefork.c" httpd.conf -A7 | /bin/sed -nE "/bMaxRequestsPerChildb/ s/[0-9]+/50/"
But no luck.
linux shell-script sed grep
I'm trying grep 7 lines after match and replace a context in those 7 lines and save it in the same file.
For Example:
<IfModule prefork.c>
StartServers 8
MinSpareServers 5
MaxSpareServers 20
ServerLimit 256
MaxClients 256
MaxRequestsPerChild 4000
</IfModule>
i would like to replace the value of MaxRequestsPerChild
with 5000
.
I have tried with:
grep "IfModule prefork.c" httpd.conf -A7 | /bin/sed -nE "/bMaxRequestsPerChildb/ s/[0-9]+/50/"
But no luck.
linux shell-script sed grep
edited Jun 21 at 9:23
SivaPrasath
3,90111737
3,90111737
asked Jun 21 at 9:20
nkmox k
186
186
why not just grep for the string you're looking for in the first place?
â imabug
Jun 21 at 9:25
1
Sorry if I'm a bit daft, but why not just change the line in an editor?
â Kusalananda
Jun 21 at 9:25
@imabug there are other modules having the same pattern.
â nkmox k
Jun 21 at 9:26
2
there is several problem here, first, you want to edit a file and you do not provide sed with a file name but with stdin. So sed will never work, I suggest you write a script that get line number with grep and then sed inline at the properline number. I will not help you make this logic a oneliner
â Kiwy
Jun 21 at 9:28
2
@nkmoxk You're administrating 73 machines. Are you thinking you would run this over SSH in a loop? Have you considered Ansible?
â Kusalananda
Jun 21 at 9:30
 |Â
show 8 more comments
why not just grep for the string you're looking for in the first place?
â imabug
Jun 21 at 9:25
1
Sorry if I'm a bit daft, but why not just change the line in an editor?
â Kusalananda
Jun 21 at 9:25
@imabug there are other modules having the same pattern.
â nkmox k
Jun 21 at 9:26
2
there is several problem here, first, you want to edit a file and you do not provide sed with a file name but with stdin. So sed will never work, I suggest you write a script that get line number with grep and then sed inline at the properline number. I will not help you make this logic a oneliner
â Kiwy
Jun 21 at 9:28
2
@nkmoxk You're administrating 73 machines. Are you thinking you would run this over SSH in a loop? Have you considered Ansible?
â Kusalananda
Jun 21 at 9:30
why not just grep for the string you're looking for in the first place?
â imabug
Jun 21 at 9:25
why not just grep for the string you're looking for in the first place?
â imabug
Jun 21 at 9:25
1
1
Sorry if I'm a bit daft, but why not just change the line in an editor?
â Kusalananda
Jun 21 at 9:25
Sorry if I'm a bit daft, but why not just change the line in an editor?
â Kusalananda
Jun 21 at 9:25
@imabug there are other modules having the same pattern.
â nkmox k
Jun 21 at 9:26
@imabug there are other modules having the same pattern.
â nkmox k
Jun 21 at 9:26
2
2
there is several problem here, first, you want to edit a file and you do not provide sed with a file name but with stdin. So sed will never work, I suggest you write a script that get line number with grep and then sed inline at the properline number. I will not help you make this logic a oneliner
â Kiwy
Jun 21 at 9:28
there is several problem here, first, you want to edit a file and you do not provide sed with a file name but with stdin. So sed will never work, I suggest you write a script that get line number with grep and then sed inline at the properline number. I will not help you make this logic a oneliner
â Kiwy
Jun 21 at 9:28
2
2
@nkmoxk You're administrating 73 machines. Are you thinking you would run this over SSH in a loop? Have you considered Ansible?
â Kusalananda
Jun 21 at 9:30
@nkmoxk You're administrating 73 machines. Are you thinking you would run this over SSH in a loop? Have you considered Ansible?
â Kusalananda
Jun 21 at 9:30
 |Â
show 8 more comments
3 Answers
3
active
oldest
votes
up vote
1
down vote
accepted
Here is a SED solution, hope it will help you.
sed '/<IfModule prefork.c>/,/MaxRequestsPerChild/s/MaxRequestsPerChild.*/MaxRequestsPerChild 5000/' apacheconf
It works by matching the Module name then replacing the next "MaxRequestsPerChild" line with the 5000 value. It will ignore the "MaxRequestsPerChild" of all other modules.
Give it a try.
1
awesome man!!!!
â nkmox k
Jun 21 at 13:28
add a comment |Â
up vote
0
down vote
With GNU sed (not sure if syntax/feature is okay for other versions)
To change within 6 lines after matching line:
sed -E '/IfModule prefork.c/N;N;N;N;N;N;s/(MaxRequestsPerChild +)[0-9]+/15000/'
here, N
will add a newline to the pattern space, then append the next line of input to the pattern space
If it is always 6th line:
sed -E '/IfModule prefork.c/n;n;n;n;n;n;s/[0-9]+/5000/'
here n
will replace the pattern space with the next line of input
Or, simpler syntax with relative addressing
sed -E '/IfModule prefork.c/,+6 s/(MaxRequestsPerChild +)[0-9]+/15000/'
Thanks, but not getting the result. Looks like problem with[0-9]+
â nkmox k
Jun 21 at 10:10
@nkmoxk can you give details.. did you get an error? or something else happened? it works for me on GNU sed(you've tagged linux, so I'm assuming you have GNU sed)
â Sundeep
Jun 21 at 10:24
its not replacing the value. if i remove+
sign, it replaces only the first digit as expected.
â nkmox k
Jun 21 at 10:27
did you usesed -E
? may be your version needssed -r
?
â Sundeep
Jun 21 at 10:46
add a comment |Â
up vote
0
down vote
You could put sed's range operator ,
to good use here in case you are indifferent to line numbers:
sed -e '
/<IfModule prefork.c>/,|</IfModule>|!b
H;|</IfModule>|!d;g;s/.//;
s/((n)MaxRequestsPerChild[[:blank:]]1,)[1-9][0-9]*n/150002/
' config-file
- Store the range in the hold space.
- When the range end is detected, retrieve the range from the hold area, and
- Perform the desired substitution.
- Lines not falling in the range are left to themselves and passed on to stdout.
sed -e ' /<IfModule prefork.c>/,|</IfModule>|!b H;|</IfModule>|!d;g;s/.//; s/((n)MaxRequestsPerChild[[:blank:]]1,)[1-9][0-9]*n/150002/ ' httpd.conf | head -n108 | tail -n1
MaxRequestsPerChild 5000
â nkmox k
Jun 21 at 12:18
Thanks, but its not substituting.
â nkmox k
Jun 21 at 12:19
@nkmoxk You cannot write thesed
command in one line as you've shown. Give each line of sed code with it's own-e
option.
â Rakesh Sharma
Jun 22 at 5:33
add a comment |Â
3 Answers
3
active
oldest
votes
3 Answers
3
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
Here is a SED solution, hope it will help you.
sed '/<IfModule prefork.c>/,/MaxRequestsPerChild/s/MaxRequestsPerChild.*/MaxRequestsPerChild 5000/' apacheconf
It works by matching the Module name then replacing the next "MaxRequestsPerChild" line with the 5000 value. It will ignore the "MaxRequestsPerChild" of all other modules.
Give it a try.
1
awesome man!!!!
â nkmox k
Jun 21 at 13:28
add a comment |Â
up vote
1
down vote
accepted
Here is a SED solution, hope it will help you.
sed '/<IfModule prefork.c>/,/MaxRequestsPerChild/s/MaxRequestsPerChild.*/MaxRequestsPerChild 5000/' apacheconf
It works by matching the Module name then replacing the next "MaxRequestsPerChild" line with the 5000 value. It will ignore the "MaxRequestsPerChild" of all other modules.
Give it a try.
1
awesome man!!!!
â nkmox k
Jun 21 at 13:28
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
Here is a SED solution, hope it will help you.
sed '/<IfModule prefork.c>/,/MaxRequestsPerChild/s/MaxRequestsPerChild.*/MaxRequestsPerChild 5000/' apacheconf
It works by matching the Module name then replacing the next "MaxRequestsPerChild" line with the 5000 value. It will ignore the "MaxRequestsPerChild" of all other modules.
Give it a try.
Here is a SED solution, hope it will help you.
sed '/<IfModule prefork.c>/,/MaxRequestsPerChild/s/MaxRequestsPerChild.*/MaxRequestsPerChild 5000/' apacheconf
It works by matching the Module name then replacing the next "MaxRequestsPerChild" line with the 5000 value. It will ignore the "MaxRequestsPerChild" of all other modules.
Give it a try.
answered Jun 21 at 13:13
K. Kirilov
514
514
1
awesome man!!!!
â nkmox k
Jun 21 at 13:28
add a comment |Â
1
awesome man!!!!
â nkmox k
Jun 21 at 13:28
1
1
awesome man!!!!
â nkmox k
Jun 21 at 13:28
awesome man!!!!
â nkmox k
Jun 21 at 13:28
add a comment |Â
up vote
0
down vote
With GNU sed (not sure if syntax/feature is okay for other versions)
To change within 6 lines after matching line:
sed -E '/IfModule prefork.c/N;N;N;N;N;N;s/(MaxRequestsPerChild +)[0-9]+/15000/'
here, N
will add a newline to the pattern space, then append the next line of input to the pattern space
If it is always 6th line:
sed -E '/IfModule prefork.c/n;n;n;n;n;n;s/[0-9]+/5000/'
here n
will replace the pattern space with the next line of input
Or, simpler syntax with relative addressing
sed -E '/IfModule prefork.c/,+6 s/(MaxRequestsPerChild +)[0-9]+/15000/'
Thanks, but not getting the result. Looks like problem with[0-9]+
â nkmox k
Jun 21 at 10:10
@nkmoxk can you give details.. did you get an error? or something else happened? it works for me on GNU sed(you've tagged linux, so I'm assuming you have GNU sed)
â Sundeep
Jun 21 at 10:24
its not replacing the value. if i remove+
sign, it replaces only the first digit as expected.
â nkmox k
Jun 21 at 10:27
did you usesed -E
? may be your version needssed -r
?
â Sundeep
Jun 21 at 10:46
add a comment |Â
up vote
0
down vote
With GNU sed (not sure if syntax/feature is okay for other versions)
To change within 6 lines after matching line:
sed -E '/IfModule prefork.c/N;N;N;N;N;N;s/(MaxRequestsPerChild +)[0-9]+/15000/'
here, N
will add a newline to the pattern space, then append the next line of input to the pattern space
If it is always 6th line:
sed -E '/IfModule prefork.c/n;n;n;n;n;n;s/[0-9]+/5000/'
here n
will replace the pattern space with the next line of input
Or, simpler syntax with relative addressing
sed -E '/IfModule prefork.c/,+6 s/(MaxRequestsPerChild +)[0-9]+/15000/'
Thanks, but not getting the result. Looks like problem with[0-9]+
â nkmox k
Jun 21 at 10:10
@nkmoxk can you give details.. did you get an error? or something else happened? it works for me on GNU sed(you've tagged linux, so I'm assuming you have GNU sed)
â Sundeep
Jun 21 at 10:24
its not replacing the value. if i remove+
sign, it replaces only the first digit as expected.
â nkmox k
Jun 21 at 10:27
did you usesed -E
? may be your version needssed -r
?
â Sundeep
Jun 21 at 10:46
add a comment |Â
up vote
0
down vote
up vote
0
down vote
With GNU sed (not sure if syntax/feature is okay for other versions)
To change within 6 lines after matching line:
sed -E '/IfModule prefork.c/N;N;N;N;N;N;s/(MaxRequestsPerChild +)[0-9]+/15000/'
here, N
will add a newline to the pattern space, then append the next line of input to the pattern space
If it is always 6th line:
sed -E '/IfModule prefork.c/n;n;n;n;n;n;s/[0-9]+/5000/'
here n
will replace the pattern space with the next line of input
Or, simpler syntax with relative addressing
sed -E '/IfModule prefork.c/,+6 s/(MaxRequestsPerChild +)[0-9]+/15000/'
With GNU sed (not sure if syntax/feature is okay for other versions)
To change within 6 lines after matching line:
sed -E '/IfModule prefork.c/N;N;N;N;N;N;s/(MaxRequestsPerChild +)[0-9]+/15000/'
here, N
will add a newline to the pattern space, then append the next line of input to the pattern space
If it is always 6th line:
sed -E '/IfModule prefork.c/n;n;n;n;n;n;s/[0-9]+/5000/'
here n
will replace the pattern space with the next line of input
Or, simpler syntax with relative addressing
sed -E '/IfModule prefork.c/,+6 s/(MaxRequestsPerChild +)[0-9]+/15000/'
edited Jun 21 at 10:06
answered Jun 21 at 10:00
Sundeep
6,9511826
6,9511826
Thanks, but not getting the result. Looks like problem with[0-9]+
â nkmox k
Jun 21 at 10:10
@nkmoxk can you give details.. did you get an error? or something else happened? it works for me on GNU sed(you've tagged linux, so I'm assuming you have GNU sed)
â Sundeep
Jun 21 at 10:24
its not replacing the value. if i remove+
sign, it replaces only the first digit as expected.
â nkmox k
Jun 21 at 10:27
did you usesed -E
? may be your version needssed -r
?
â Sundeep
Jun 21 at 10:46
add a comment |Â
Thanks, but not getting the result. Looks like problem with[0-9]+
â nkmox k
Jun 21 at 10:10
@nkmoxk can you give details.. did you get an error? or something else happened? it works for me on GNU sed(you've tagged linux, so I'm assuming you have GNU sed)
â Sundeep
Jun 21 at 10:24
its not replacing the value. if i remove+
sign, it replaces only the first digit as expected.
â nkmox k
Jun 21 at 10:27
did you usesed -E
? may be your version needssed -r
?
â Sundeep
Jun 21 at 10:46
Thanks, but not getting the result. Looks like problem with
[0-9]+
â nkmox k
Jun 21 at 10:10
Thanks, but not getting the result. Looks like problem with
[0-9]+
â nkmox k
Jun 21 at 10:10
@nkmoxk can you give details.. did you get an error? or something else happened? it works for me on GNU sed(you've tagged linux, so I'm assuming you have GNU sed)
â Sundeep
Jun 21 at 10:24
@nkmoxk can you give details.. did you get an error? or something else happened? it works for me on GNU sed(you've tagged linux, so I'm assuming you have GNU sed)
â Sundeep
Jun 21 at 10:24
its not replacing the value. if i remove
+
sign, it replaces only the first digit as expected.â nkmox k
Jun 21 at 10:27
its not replacing the value. if i remove
+
sign, it replaces only the first digit as expected.â nkmox k
Jun 21 at 10:27
did you use
sed -E
? may be your version needs sed -r
?â Sundeep
Jun 21 at 10:46
did you use
sed -E
? may be your version needs sed -r
?â Sundeep
Jun 21 at 10:46
add a comment |Â
up vote
0
down vote
You could put sed's range operator ,
to good use here in case you are indifferent to line numbers:
sed -e '
/<IfModule prefork.c>/,|</IfModule>|!b
H;|</IfModule>|!d;g;s/.//;
s/((n)MaxRequestsPerChild[[:blank:]]1,)[1-9][0-9]*n/150002/
' config-file
- Store the range in the hold space.
- When the range end is detected, retrieve the range from the hold area, and
- Perform the desired substitution.
- Lines not falling in the range are left to themselves and passed on to stdout.
sed -e ' /<IfModule prefork.c>/,|</IfModule>|!b H;|</IfModule>|!d;g;s/.//; s/((n)MaxRequestsPerChild[[:blank:]]1,)[1-9][0-9]*n/150002/ ' httpd.conf | head -n108 | tail -n1
MaxRequestsPerChild 5000
â nkmox k
Jun 21 at 12:18
Thanks, but its not substituting.
â nkmox k
Jun 21 at 12:19
@nkmoxk You cannot write thesed
command in one line as you've shown. Give each line of sed code with it's own-e
option.
â Rakesh Sharma
Jun 22 at 5:33
add a comment |Â
up vote
0
down vote
You could put sed's range operator ,
to good use here in case you are indifferent to line numbers:
sed -e '
/<IfModule prefork.c>/,|</IfModule>|!b
H;|</IfModule>|!d;g;s/.//;
s/((n)MaxRequestsPerChild[[:blank:]]1,)[1-9][0-9]*n/150002/
' config-file
- Store the range in the hold space.
- When the range end is detected, retrieve the range from the hold area, and
- Perform the desired substitution.
- Lines not falling in the range are left to themselves and passed on to stdout.
sed -e ' /<IfModule prefork.c>/,|</IfModule>|!b H;|</IfModule>|!d;g;s/.//; s/((n)MaxRequestsPerChild[[:blank:]]1,)[1-9][0-9]*n/150002/ ' httpd.conf | head -n108 | tail -n1
MaxRequestsPerChild 5000
â nkmox k
Jun 21 at 12:18
Thanks, but its not substituting.
â nkmox k
Jun 21 at 12:19
@nkmoxk You cannot write thesed
command in one line as you've shown. Give each line of sed code with it's own-e
option.
â Rakesh Sharma
Jun 22 at 5:33
add a comment |Â
up vote
0
down vote
up vote
0
down vote
You could put sed's range operator ,
to good use here in case you are indifferent to line numbers:
sed -e '
/<IfModule prefork.c>/,|</IfModule>|!b
H;|</IfModule>|!d;g;s/.//;
s/((n)MaxRequestsPerChild[[:blank:]]1,)[1-9][0-9]*n/150002/
' config-file
- Store the range in the hold space.
- When the range end is detected, retrieve the range from the hold area, and
- Perform the desired substitution.
- Lines not falling in the range are left to themselves and passed on to stdout.
You could put sed's range operator ,
to good use here in case you are indifferent to line numbers:
sed -e '
/<IfModule prefork.c>/,|</IfModule>|!b
H;|</IfModule>|!d;g;s/.//;
s/((n)MaxRequestsPerChild[[:blank:]]1,)[1-9][0-9]*n/150002/
' config-file
- Store the range in the hold space.
- When the range end is detected, retrieve the range from the hold area, and
- Perform the desired substitution.
- Lines not falling in the range are left to themselves and passed on to stdout.
answered Jun 21 at 11:09
Rakesh Sharma
3683
3683
sed -e ' /<IfModule prefork.c>/,|</IfModule>|!b H;|</IfModule>|!d;g;s/.//; s/((n)MaxRequestsPerChild[[:blank:]]1,)[1-9][0-9]*n/150002/ ' httpd.conf | head -n108 | tail -n1
MaxRequestsPerChild 5000
â nkmox k
Jun 21 at 12:18
Thanks, but its not substituting.
â nkmox k
Jun 21 at 12:19
@nkmoxk You cannot write thesed
command in one line as you've shown. Give each line of sed code with it's own-e
option.
â Rakesh Sharma
Jun 22 at 5:33
add a comment |Â
sed -e ' /<IfModule prefork.c>/,|</IfModule>|!b H;|</IfModule>|!d;g;s/.//; s/((n)MaxRequestsPerChild[[:blank:]]1,)[1-9][0-9]*n/150002/ ' httpd.conf | head -n108 | tail -n1
MaxRequestsPerChild 5000
â nkmox k
Jun 21 at 12:18
Thanks, but its not substituting.
â nkmox k
Jun 21 at 12:19
@nkmoxk You cannot write thesed
command in one line as you've shown. Give each line of sed code with it's own-e
option.
â Rakesh Sharma
Jun 22 at 5:33
sed -e ' /<IfModule prefork.c>/,|</IfModule>|!b H;|</IfModule>|!d;g;s/.//; s/((n)MaxRequestsPerChild[[:blank:]]1,)[1-9][0-9]*n/150002/ ' httpd.conf | head -n108 | tail -n1
MaxRequestsPerChild 5000â nkmox k
Jun 21 at 12:18
sed -e ' /<IfModule prefork.c>/,|</IfModule>|!b H;|</IfModule>|!d;g;s/.//; s/((n)MaxRequestsPerChild[[:blank:]]1,)[1-9][0-9]*n/150002/ ' httpd.conf | head -n108 | tail -n1
MaxRequestsPerChild 5000â nkmox k
Jun 21 at 12:18
Thanks, but its not substituting.
â nkmox k
Jun 21 at 12:19
Thanks, but its not substituting.
â nkmox k
Jun 21 at 12:19
@nkmoxk You cannot write the
sed
command in one line as you've shown. Give each line of sed code with it's own -e
option.â Rakesh Sharma
Jun 22 at 5:33
@nkmoxk You cannot write the
sed
command in one line as you've shown. Give each line of sed code with it's own -e
option.â Rakesh Sharma
Jun 22 at 5:33
add a comment |Â
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f451053%2fhow-to-grep-7-lines-after-match-and-replace-text%23new-answer', 'question_page');
);
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function ()
StackExchange.helpers.onClickDraftSave('#login-link');
);
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
why not just grep for the string you're looking for in the first place?
â imabug
Jun 21 at 9:25
1
Sorry if I'm a bit daft, but why not just change the line in an editor?
â Kusalananda
Jun 21 at 9:25
@imabug there are other modules having the same pattern.
â nkmox k
Jun 21 at 9:26
2
there is several problem here, first, you want to edit a file and you do not provide sed with a file name but with stdin. So sed will never work, I suggest you write a script that get line number with grep and then sed inline at the properline number. I will not help you make this logic a oneliner
â Kiwy
Jun 21 at 9:28
2
@nkmoxk You're administrating 73 machines. Are you thinking you would run this over SSH in a loop? Have you considered Ansible?
â Kusalananda
Jun 21 at 9:30