Remove entire lines form text file based on URL form 12 colum

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP











up vote
-1
down vote

favorite












I have a file abc.txt in that file having 29 records In these records we need to remove some of the lines which are having the url based on the URL http://163.172.47.140:55555/



For example:



- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323 






share|improve this question






















  • Have you tried with a text editor, eg. vi ?
    – Gerard H. Pille
    Jan 23 at 9:18














up vote
-1
down vote

favorite












I have a file abc.txt in that file having 29 records In these records we need to remove some of the lines which are having the url based on the URL http://163.172.47.140:55555/



For example:



- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323 






share|improve this question






















  • Have you tried with a text editor, eg. vi ?
    – Gerard H. Pille
    Jan 23 at 9:18












up vote
-1
down vote

favorite









up vote
-1
down vote

favorite











I have a file abc.txt in that file having 29 records In these records we need to remove some of the lines which are having the url based on the URL http://163.172.47.140:55555/



For example:



- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323 






share|improve this question














I have a file abc.txt in that file having 29 records In these records we need to remove some of the lines which are having the url based on the URL http://163.172.47.140:55555/



For example:



- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323 








share|improve this question













share|improve this question




share|improve this question








edited Jan 23 at 9:21









andcoz

11.7k32938




11.7k32938










asked Jan 23 at 9:15









Ramadevi Palagani

12




12











  • Have you tried with a text editor, eg. vi ?
    – Gerard H. Pille
    Jan 23 at 9:18
















  • Have you tried with a text editor, eg. vi ?
    – Gerard H. Pille
    Jan 23 at 9:18















Have you tried with a text editor, eg. vi ?
– Gerard H. Pille
Jan 23 at 9:18




Have you tried with a text editor, eg. vi ?
– Gerard H. Pille
Jan 23 at 9:18










3 Answers
3






active

oldest

votes

















up vote
1
down vote













With sed command:



Sample input.txt:



- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://192.172.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323



sed -i '/http://163.172.47.140:55555//d' input.txt



  • -i - edit file inplace


  • d - delete records matching a certain pattern

The final input.txt contents:



- 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://192.172.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323





share|improve this answer



























    up vote
    1
    down vote













    grep -vF 'http://163.172.47.140:55555/' input



    • -vF str - all lines that don't contain str





    share|improve this answer




















    • I want to remove the entire line with this 163.172.47.140:55555
      – Ramadevi Palagani
      Jan 26 at 11:48

















    up vote
    1
    down vote













    Inputfile



    - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
    - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://195.175.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
    - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323


    Below command delete the lines which contains "http://163.172.47.140:55555"



    Command:



     awk '!/http://163.172.47.140:55555/print $0' inputfile


    output



    - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://195.175.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323





    share|improve this answer




















    • cool and readable ... or even awk '!/http://163.172.47.140:55555/'
      – JJoao
      Jan 24 at 8:17










    Your Answer







    StackExchange.ready(function()
    var channelOptions =
    tags: "".split(" "),
    id: "106"
    ;
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function()
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled)
    StackExchange.using("snippets", function()
    createEditor();
    );

    else
    createEditor();

    );

    function createEditor()
    StackExchange.prepareEditor(
    heartbeatType: 'answer',
    convertImagesToLinks: false,
    noModals: false,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    );



    );








     

    draft saved


    draft discarded


















    StackExchange.ready(
    function ()
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f419036%2fremove-entire-lines-form-text-file-based-on-url-form-12-colum%23new-answer', 'question_page');

    );

    Post as a guest






























    3 Answers
    3






    active

    oldest

    votes








    3 Answers
    3






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    With sed command:



    Sample input.txt:



    - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
    - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://192.172.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
    - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323



    sed -i '/http://163.172.47.140:55555//d' input.txt



    • -i - edit file inplace


    • d - delete records matching a certain pattern

    The final input.txt contents:



    - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://192.172.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323





    share|improve this answer
























      up vote
      1
      down vote













      With sed command:



      Sample input.txt:



      - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
      - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://192.172.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
      - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323



      sed -i '/http://163.172.47.140:55555//d' input.txt



      • -i - edit file inplace


      • d - delete records matching a certain pattern

      The final input.txt contents:



      - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://192.172.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323





      share|improve this answer






















        up vote
        1
        down vote










        up vote
        1
        down vote









        With sed command:



        Sample input.txt:



        - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
        - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://192.172.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
        - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323



        sed -i '/http://163.172.47.140:55555//d' input.txt



        • -i - edit file inplace


        • d - delete records matching a certain pattern

        The final input.txt contents:



        - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://192.172.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323





        share|improve this answer












        With sed command:



        Sample input.txt:



        - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
        - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://192.172.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
        - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323



        sed -i '/http://163.172.47.140:55555//d' input.txt



        • -i - edit file inplace


        • d - delete records matching a certain pattern

        The final input.txt contents:



        - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://192.172.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323






        share|improve this answer












        share|improve this answer



        share|improve this answer










        answered Jan 23 at 9:29









        RomanPerekhrest

        22.4k12144




        22.4k12144






















            up vote
            1
            down vote













            grep -vF 'http://163.172.47.140:55555/' input



            • -vF str - all lines that don't contain str





            share|improve this answer




















            • I want to remove the entire line with this 163.172.47.140:55555
              – Ramadevi Palagani
              Jan 26 at 11:48














            up vote
            1
            down vote













            grep -vF 'http://163.172.47.140:55555/' input



            • -vF str - all lines that don't contain str





            share|improve this answer




















            • I want to remove the entire line with this 163.172.47.140:55555
              – Ramadevi Palagani
              Jan 26 at 11:48












            up vote
            1
            down vote










            up vote
            1
            down vote









            grep -vF 'http://163.172.47.140:55555/' input



            • -vF str - all lines that don't contain str





            share|improve this answer












            grep -vF 'http://163.172.47.140:55555/' input



            • -vF str - all lines that don't contain str






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 23 at 11:03









            JJoao

            6,7211826




            6,7211826











            • I want to remove the entire line with this 163.172.47.140:55555
              – Ramadevi Palagani
              Jan 26 at 11:48
















            • I want to remove the entire line with this 163.172.47.140:55555
              – Ramadevi Palagani
              Jan 26 at 11:48















            I want to remove the entire line with this 163.172.47.140:55555
            – Ramadevi Palagani
            Jan 26 at 11:48




            I want to remove the entire line with this 163.172.47.140:55555
            – Ramadevi Palagani
            Jan 26 at 11:48










            up vote
            1
            down vote













            Inputfile



            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://195.175.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323


            Below command delete the lines which contains "http://163.172.47.140:55555"



            Command:



             awk '!/http://163.172.47.140:55555/print $0' inputfile


            output



            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://195.175.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323





            share|improve this answer




















            • cool and readable ... or even awk '!/http://163.172.47.140:55555/'
              – JJoao
              Jan 24 at 8:17














            up vote
            1
            down vote













            Inputfile



            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://195.175.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323


            Below command delete the lines which contains "http://163.172.47.140:55555"



            Command:



             awk '!/http://163.172.47.140:55555/print $0' inputfile


            output



            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://195.175.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323





            share|improve this answer




















            • cool and readable ... or even awk '!/http://163.172.47.140:55555/'
              – JJoao
              Jan 24 at 8:17












            up vote
            1
            down vote










            up vote
            1
            down vote









            Inputfile



            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://195.175.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323


            Below command delete the lines which contains "http://163.172.47.140:55555"



            Command:



             awk '!/http://163.172.47.140:55555/print $0' inputfile


            output



            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://195.175.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323





            share|improve this answer












            Inputfile



            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://195.175.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323
            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://163.172.47.140:55555/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323


            Below command delete the lines which contains "http://163.172.47.140:55555"



            Command:



             awk '!/http://163.172.47.140:55555/print $0' inputfile


            output



            - 163.12372.473.1440 35010 2018-01-18 01:03:13 +0000 POST http://195.175.45.130:55550/?oip=163.172.47.140 HTTP/1.1 200 147 -est_useragent - - test_refe test_useragent - - test_referer text/json 323






            share|improve this answer












            share|improve this answer



            share|improve this answer










            answered Jan 23 at 14:42









            Praveen Kumar BS

            1,010128




            1,010128











            • cool and readable ... or even awk '!/http://163.172.47.140:55555/'
              – JJoao
              Jan 24 at 8:17
















            • cool and readable ... or even awk '!/http://163.172.47.140:55555/'
              – JJoao
              Jan 24 at 8:17















            cool and readable ... or even awk '!/http://163.172.47.140:55555/'
            – JJoao
            Jan 24 at 8:17




            cool and readable ... or even awk '!/http://163.172.47.140:55555/'
            – JJoao
            Jan 24 at 8:17












             

            draft saved


            draft discarded


























             


            draft saved


            draft discarded














            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f419036%2fremove-entire-lines-form-text-file-based-on-url-form-12-colum%23new-answer', 'question_page');

            );

            Post as a guest













































































            Popular posts from this blog

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

            Bahrain

            Postfix configuration issue with fips on centos 7; mailgun relay