Delete a partiular line and 17 lines after that [duplicate]
Clash Royale CLAN TAG#URR8PPP
up vote
-2
down vote
favorite
This question already has an answer here:
Remove line containing certain string and the following line
5 answers
I have a report that pulls some information IP address and host name, etc.
Some some servers have a heading like:
NOTICE TO USERS
(followed by about 17 lines of text information)
when I cat the file, I do not need the NOTICE (and 17 more line after that on some servers). How can I get rid of it?
shell-script
marked as duplicate by don_crissti, jimmij, ñÃÂsýù÷, steve, Isaac Apr 2 at 20:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
add a comment |Â
up vote
-2
down vote
favorite
This question already has an answer here:
Remove line containing certain string and the following line
5 answers
I have a report that pulls some information IP address and host name, etc.
Some some servers have a heading like:
NOTICE TO USERS
(followed by about 17 lines of text information)
when I cat the file, I do not need the NOTICE (and 17 more line after that on some servers). How can I get rid of it?
shell-script
marked as duplicate by don_crissti, jimmij, ñÃÂsýù÷, steve, Isaac Apr 2 at 20:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
"about 17 lines"...?
â Hauke Laging
Apr 2 at 15:37
2
We expect the question's requirements to be more precise. Show some sample text and explain which lines you want to exclude.
â glenn jackman
Apr 2 at 15:43
add a comment |Â
up vote
-2
down vote
favorite
up vote
-2
down vote
favorite
This question already has an answer here:
Remove line containing certain string and the following line
5 answers
I have a report that pulls some information IP address and host name, etc.
Some some servers have a heading like:
NOTICE TO USERS
(followed by about 17 lines of text information)
when I cat the file, I do not need the NOTICE (and 17 more line after that on some servers). How can I get rid of it?
shell-script
This question already has an answer here:
Remove line containing certain string and the following line
5 answers
I have a report that pulls some information IP address and host name, etc.
Some some servers have a heading like:
NOTICE TO USERS
(followed by about 17 lines of text information)
when I cat the file, I do not need the NOTICE (and 17 more line after that on some servers). How can I get rid of it?
This question already has an answer here:
Remove line containing certain string and the following line
5 answers
shell-script
asked Apr 2 at 15:32
tester787
9028
9028
marked as duplicate by don_crissti, jimmij, ñÃÂsýù÷, steve, Isaac Apr 2 at 20:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
marked as duplicate by don_crissti, jimmij, ñÃÂsýù÷, steve, Isaac Apr 2 at 20:13
This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.
"about 17 lines"...?
â Hauke Laging
Apr 2 at 15:37
2
We expect the question's requirements to be more precise. Show some sample text and explain which lines you want to exclude.
â glenn jackman
Apr 2 at 15:43
add a comment |Â
"about 17 lines"...?
â Hauke Laging
Apr 2 at 15:37
2
We expect the question's requirements to be more precise. Show some sample text and explain which lines you want to exclude.
â glenn jackman
Apr 2 at 15:43
"about 17 lines"...?
â Hauke Laging
Apr 2 at 15:37
"about 17 lines"...?
â Hauke Laging
Apr 2 at 15:37
2
2
We expect the question's requirements to be more precise. Show some sample text and explain which lines you want to exclude.
â glenn jackman
Apr 2 at 15:43
We expect the question's requirements to be more precise. Show some sample text and explain which lines you want to exclude.
â glenn jackman
Apr 2 at 15:43
add a comment |Â
2 Answers
2
active
oldest
votes
up vote
1
down vote
accepted
You can use below sed command to achieve the same
sed '/NOTICE TO USERS/,+17d' filename
IF you want to delete the 17lines with NOTICE TO USERS line in same file means you can use -i option in sed command
sed -i '/NOTICE TO USERS/,+17d' filename
add a comment |Â
up vote
2
down vote
awk '/NOTICE TO USERS/ lastdelline=NR+17 ;
lastdelline>0 && NR<=lastdelline next; ; print; ' inputfile
WhyNR+5
and notNR+17
?
â codeforester
Apr 2 at 15:42
3
@codeforester 5 is "about" 17 :-)
â nohillside
Apr 2 at 15:44
I tried the awk commnad, it did not take out any thing. The NOTICE TO USERS (followed by 17 lines) is a part of /etc/issue. My script does ssh from on server to a number of servers and gathers information like IP, host name ,etc. I am still trying to get rid off NOTICE TO USERS (followed by 17 lines) which appears on some servers. I appreciate any help.
â tester787
Apr 2 at 16:23
It worked this time, thank you very much.
â tester787
Apr 2 at 16:43
awk '/NOTICE TO USERS/ lastdelline=NR+17 ; lastdelline>0 && NR<=lastdelline next; ; print; ' test.info
â tester787
Apr 2 at 16:43
add a comment |Â
2 Answers
2
active
oldest
votes
2 Answers
2
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
1
down vote
accepted
You can use below sed command to achieve the same
sed '/NOTICE TO USERS/,+17d' filename
IF you want to delete the 17lines with NOTICE TO USERS line in same file means you can use -i option in sed command
sed -i '/NOTICE TO USERS/,+17d' filename
add a comment |Â
up vote
1
down vote
accepted
You can use below sed command to achieve the same
sed '/NOTICE TO USERS/,+17d' filename
IF you want to delete the 17lines with NOTICE TO USERS line in same file means you can use -i option in sed command
sed -i '/NOTICE TO USERS/,+17d' filename
add a comment |Â
up vote
1
down vote
accepted
up vote
1
down vote
accepted
You can use below sed command to achieve the same
sed '/NOTICE TO USERS/,+17d' filename
IF you want to delete the 17lines with NOTICE TO USERS line in same file means you can use -i option in sed command
sed -i '/NOTICE TO USERS/,+17d' filename
You can use below sed command to achieve the same
sed '/NOTICE TO USERS/,+17d' filename
IF you want to delete the 17lines with NOTICE TO USERS line in same file means you can use -i option in sed command
sed -i '/NOTICE TO USERS/,+17d' filename
answered Apr 2 at 18:10
Praveen Kumar BS
1,010128
1,010128
add a comment |Â
add a comment |Â
up vote
2
down vote
awk '/NOTICE TO USERS/ lastdelline=NR+17 ;
lastdelline>0 && NR<=lastdelline next; ; print; ' inputfile
WhyNR+5
and notNR+17
?
â codeforester
Apr 2 at 15:42
3
@codeforester 5 is "about" 17 :-)
â nohillside
Apr 2 at 15:44
I tried the awk commnad, it did not take out any thing. The NOTICE TO USERS (followed by 17 lines) is a part of /etc/issue. My script does ssh from on server to a number of servers and gathers information like IP, host name ,etc. I am still trying to get rid off NOTICE TO USERS (followed by 17 lines) which appears on some servers. I appreciate any help.
â tester787
Apr 2 at 16:23
It worked this time, thank you very much.
â tester787
Apr 2 at 16:43
awk '/NOTICE TO USERS/ lastdelline=NR+17 ; lastdelline>0 && NR<=lastdelline next; ; print; ' test.info
â tester787
Apr 2 at 16:43
add a comment |Â
up vote
2
down vote
awk '/NOTICE TO USERS/ lastdelline=NR+17 ;
lastdelline>0 && NR<=lastdelline next; ; print; ' inputfile
WhyNR+5
and notNR+17
?
â codeforester
Apr 2 at 15:42
3
@codeforester 5 is "about" 17 :-)
â nohillside
Apr 2 at 15:44
I tried the awk commnad, it did not take out any thing. The NOTICE TO USERS (followed by 17 lines) is a part of /etc/issue. My script does ssh from on server to a number of servers and gathers information like IP, host name ,etc. I am still trying to get rid off NOTICE TO USERS (followed by 17 lines) which appears on some servers. I appreciate any help.
â tester787
Apr 2 at 16:23
It worked this time, thank you very much.
â tester787
Apr 2 at 16:43
awk '/NOTICE TO USERS/ lastdelline=NR+17 ; lastdelline>0 && NR<=lastdelline next; ; print; ' test.info
â tester787
Apr 2 at 16:43
add a comment |Â
up vote
2
down vote
up vote
2
down vote
awk '/NOTICE TO USERS/ lastdelline=NR+17 ;
lastdelline>0 && NR<=lastdelline next; ; print; ' inputfile
awk '/NOTICE TO USERS/ lastdelline=NR+17 ;
lastdelline>0 && NR<=lastdelline next; ; print; ' inputfile
edited Apr 2 at 16:26
answered Apr 2 at 15:40
Hauke Laging
53.2k1282130
53.2k1282130
WhyNR+5
and notNR+17
?
â codeforester
Apr 2 at 15:42
3
@codeforester 5 is "about" 17 :-)
â nohillside
Apr 2 at 15:44
I tried the awk commnad, it did not take out any thing. The NOTICE TO USERS (followed by 17 lines) is a part of /etc/issue. My script does ssh from on server to a number of servers and gathers information like IP, host name ,etc. I am still trying to get rid off NOTICE TO USERS (followed by 17 lines) which appears on some servers. I appreciate any help.
â tester787
Apr 2 at 16:23
It worked this time, thank you very much.
â tester787
Apr 2 at 16:43
awk '/NOTICE TO USERS/ lastdelline=NR+17 ; lastdelline>0 && NR<=lastdelline next; ; print; ' test.info
â tester787
Apr 2 at 16:43
add a comment |Â
WhyNR+5
and notNR+17
?
â codeforester
Apr 2 at 15:42
3
@codeforester 5 is "about" 17 :-)
â nohillside
Apr 2 at 15:44
I tried the awk commnad, it did not take out any thing. The NOTICE TO USERS (followed by 17 lines) is a part of /etc/issue. My script does ssh from on server to a number of servers and gathers information like IP, host name ,etc. I am still trying to get rid off NOTICE TO USERS (followed by 17 lines) which appears on some servers. I appreciate any help.
â tester787
Apr 2 at 16:23
It worked this time, thank you very much.
â tester787
Apr 2 at 16:43
awk '/NOTICE TO USERS/ lastdelline=NR+17 ; lastdelline>0 && NR<=lastdelline next; ; print; ' test.info
â tester787
Apr 2 at 16:43
Why
NR+5
and not NR+17
?â codeforester
Apr 2 at 15:42
Why
NR+5
and not NR+17
?â codeforester
Apr 2 at 15:42
3
3
@codeforester 5 is "about" 17 :-)
â nohillside
Apr 2 at 15:44
@codeforester 5 is "about" 17 :-)
â nohillside
Apr 2 at 15:44
I tried the awk commnad, it did not take out any thing. The NOTICE TO USERS (followed by 17 lines) is a part of /etc/issue. My script does ssh from on server to a number of servers and gathers information like IP, host name ,etc. I am still trying to get rid off NOTICE TO USERS (followed by 17 lines) which appears on some servers. I appreciate any help.
â tester787
Apr 2 at 16:23
I tried the awk commnad, it did not take out any thing. The NOTICE TO USERS (followed by 17 lines) is a part of /etc/issue. My script does ssh from on server to a number of servers and gathers information like IP, host name ,etc. I am still trying to get rid off NOTICE TO USERS (followed by 17 lines) which appears on some servers. I appreciate any help.
â tester787
Apr 2 at 16:23
It worked this time, thank you very much.
â tester787
Apr 2 at 16:43
It worked this time, thank you very much.
â tester787
Apr 2 at 16:43
awk '/NOTICE TO USERS/ lastdelline=NR+17 ; lastdelline>0 && NR<=lastdelline next; ; print; ' test.info
â tester787
Apr 2 at 16:43
awk '/NOTICE TO USERS/ lastdelline=NR+17 ; lastdelline>0 && NR<=lastdelline next; ; print; ' test.info
â tester787
Apr 2 at 16:43
add a comment |Â
"about 17 lines"...?
â Hauke Laging
Apr 2 at 15:37
2
We expect the question's requirements to be more precise. Show some sample text and explain which lines you want to exclude.
â glenn jackman
Apr 2 at 15:43