Delete a partiular line and 17 lines after that [duplicate]

The name of the pictureThe name of the pictureThe name of the pictureClash 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?







share|improve this 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














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?







share|improve this 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












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?







share|improve this question













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









share|improve this question











share|improve this question




share|improve this question










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
















  • "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










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





share|improve this answer



























    up vote
    2
    down vote













    awk '/NOTICE TO USERS/ lastdelline=NR+17 ;
    lastdelline>0 && NR<=lastdelline next; ; print; ' inputfile





    share|improve this answer






















    • Why NR+5 and not NR+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

















    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





    share|improve this answer
























      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





      share|improve this answer






















        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





        share|improve this answer












        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






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Apr 2 at 18:10









        Praveen Kumar BS

        1,010128




        1,010128






















            up vote
            2
            down vote













            awk '/NOTICE TO USERS/ lastdelline=NR+17 ;
            lastdelline>0 && NR<=lastdelline next; ; print; ' inputfile





            share|improve this answer






















            • Why NR+5 and not NR+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














            up vote
            2
            down vote













            awk '/NOTICE TO USERS/ lastdelline=NR+17 ;
            lastdelline>0 && NR<=lastdelline next; ; print; ' inputfile





            share|improve this answer






















            • Why NR+5 and not NR+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












            up vote
            2
            down vote










            up vote
            2
            down vote









            awk '/NOTICE TO USERS/ lastdelline=NR+17 ;
            lastdelline>0 && NR<=lastdelline next; ; print; ' inputfile





            share|improve this answer














            awk '/NOTICE TO USERS/ lastdelline=NR+17 ;
            lastdelline>0 && NR<=lastdelline next; ; print; ' inputfile






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Apr 2 at 16:26

























            answered Apr 2 at 15:40









            Hauke Laging

            53.2k1282130




            53.2k1282130











            • Why NR+5 and not NR+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






            • 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


            Popular posts from this blog

            How to check contact read email or not when send email to Individual?

            Displaying single band from multi-band raster using QGIS

            How many registers does an x86_64 CPU actually have?