Grep only a given number of lines after matchHow to show lines after each grep match until other specific...

What is the probability of a biased coin coming up heads given that a liar is claiming that the coin came up heads?

Repeated! Factorials!

Best way to explain to my boss that I cannot attend a team summit because it is on Rosh Hashana or any other Jewish Holiday

What does the ISO setting for mechanical 35mm film cameras actually do?

What are the function of EM and EN spaces?

I was contacted by a private bank overseas to get my inheritance

London underground zone 1-2 train ticket

…down the primrose path

Why did the US Airways Flight 1549 passengers stay on the wings?

Non-small objects in categories

Which pronoun to replace an infinitive?

Is the first page of a novel really that important?

Did Captain America make out with his niece?

Ancients don't give a full level?

Does a 4 bladed prop have almost twice the thrust of a 2 bladed prop?

What prevents ads from reading my password as I type it?

Can I enter a rental property without giving notice if I'm afraid a tenant may be hurt?

Premier League simulation

Not been paid even after reminding the Treasurer; what should I do?

In MTG, was there ever a five-color deck that worked well?

If someone else uploads my GPL'd code to Github without my permission, is that a copyright violation?

The Game of the Century - why didn't Byrne take the rook after he forked Fischer?

Only charge capacitor when button pushed then turn on LED momentarily with capacitor when button released

Definitional equality of two propositions about propositional equality



Grep only a given number of lines after match


How to show lines after each grep match until other specific match?Exclude files that have very long lines of text from grep outputExtend grep to find a match after the first matchHow can I count the number of lines in a file after a grep match?Print n lines before match1 AND the lines after match1 until match2How to match a pattern in lines before another pattern matchAppend new lines to stream, until certain number is reachedCombine lines after grep -BHow to grep 7 lines after match and replace text?Grep doesn't work when trying to match a word from a file in a second file






.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty{ margin-bottom:0;
}







0















I need to create a new file from a grep match but with maximum number of lines.



Something equivalent to this but one-liner



$ cat my_log_file.log | grep -v auto > filtered.log

$ tail -n 1000 filtered.log > filtered_1000_lines.log









share|improve this question









New contributor



Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






















  • Does your system's version of grep support the -m NUM, --max-count=NUM option?

    – steeldriver
    53 mins ago











  • @steeldriver it does, so the command is grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log

    – Juan-Kabbali
    43 mins ago








  • 1





    You say that you want to grep a given number of lines after a match but your code actually prints the last 1000 lines of the file to which you appended the results of grep -v auto. More clarity is needed on what you are trying to do.

    – Nasir Riley
    43 mins ago




















0















I need to create a new file from a grep match but with maximum number of lines.



Something equivalent to this but one-liner



$ cat my_log_file.log | grep -v auto > filtered.log

$ tail -n 1000 filtered.log > filtered_1000_lines.log









share|improve this question









New contributor



Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






















  • Does your system's version of grep support the -m NUM, --max-count=NUM option?

    – steeldriver
    53 mins ago











  • @steeldriver it does, so the command is grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log

    – Juan-Kabbali
    43 mins ago








  • 1





    You say that you want to grep a given number of lines after a match but your code actually prints the last 1000 lines of the file to which you appended the results of grep -v auto. More clarity is needed on what you are trying to do.

    – Nasir Riley
    43 mins ago
















0












0








0


1






I need to create a new file from a grep match but with maximum number of lines.



Something equivalent to this but one-liner



$ cat my_log_file.log | grep -v auto > filtered.log

$ tail -n 1000 filtered.log > filtered_1000_lines.log









share|improve this question









New contributor



Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











I need to create a new file from a grep match but with maximum number of lines.



Something equivalent to this but one-liner



$ cat my_log_file.log | grep -v auto > filtered.log

$ tail -n 1000 filtered.log > filtered_1000_lines.log






linux grep






share|improve this question









New contributor



Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.










share|improve this question









New contributor



Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








share|improve this question




share|improve this question








edited 17 mins ago









Jeff Schaller

48.5k11 gold badges72 silver badges162 bronze badges




48.5k11 gold badges72 silver badges162 bronze badges






New contributor



Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








asked 56 mins ago









Juan-KabbaliJuan-Kabbali

12 bronze badges




12 bronze badges




New contributor



Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.




New contributor




Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.


















  • Does your system's version of grep support the -m NUM, --max-count=NUM option?

    – steeldriver
    53 mins ago











  • @steeldriver it does, so the command is grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log

    – Juan-Kabbali
    43 mins ago








  • 1





    You say that you want to grep a given number of lines after a match but your code actually prints the last 1000 lines of the file to which you appended the results of grep -v auto. More clarity is needed on what you are trying to do.

    – Nasir Riley
    43 mins ago





















  • Does your system's version of grep support the -m NUM, --max-count=NUM option?

    – steeldriver
    53 mins ago











  • @steeldriver it does, so the command is grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log

    – Juan-Kabbali
    43 mins ago








  • 1





    You say that you want to grep a given number of lines after a match but your code actually prints the last 1000 lines of the file to which you appended the results of grep -v auto. More clarity is needed on what you are trying to do.

    – Nasir Riley
    43 mins ago



















Does your system's version of grep support the -m NUM, --max-count=NUM option?

– steeldriver
53 mins ago





Does your system's version of grep support the -m NUM, --max-count=NUM option?

– steeldriver
53 mins ago













@steeldriver it does, so the command is grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log

– Juan-Kabbali
43 mins ago







@steeldriver it does, so the command is grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log

– Juan-Kabbali
43 mins ago






1




1





You say that you want to grep a given number of lines after a match but your code actually prints the last 1000 lines of the file to which you appended the results of grep -v auto. More clarity is needed on what you are trying to do.

– Nasir Riley
43 mins ago







You say that you want to grep a given number of lines after a match but your code actually prints the last 1000 lines of the file to which you appended the results of grep -v auto. More clarity is needed on what you are trying to do.

– Nasir Riley
43 mins ago












1 Answer
1






active

oldest

votes


















0














The answer is



$ grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log


Where -m NUM, --max-count is the maximum number of matched lines to stop the command, so the filtered_1000_lines.log will be feed with the first 1000 matched lines.






share|improve this answer








New contributor



Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
























    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',
    autoActivateHeartbeat: false,
    convertImagesToLinks: false,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: null,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });






    Juan-Kabbali is a new contributor. Be nice, and check out our Code of Conduct.










    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f534256%2fgrep-only-a-given-number-of-lines-after-match%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes









    0














    The answer is



    $ grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log


    Where -m NUM, --max-count is the maximum number of matched lines to stop the command, so the filtered_1000_lines.log will be feed with the first 1000 matched lines.






    share|improve this answer








    New contributor



    Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
    Check out our Code of Conduct.


























      0














      The answer is



      $ grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log


      Where -m NUM, --max-count is the maximum number of matched lines to stop the command, so the filtered_1000_lines.log will be feed with the first 1000 matched lines.






      share|improve this answer








      New contributor



      Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
      Check out our Code of Conduct.
























        0












        0








        0







        The answer is



        $ grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log


        Where -m NUM, --max-count is the maximum number of matched lines to stop the command, so the filtered_1000_lines.log will be feed with the first 1000 matched lines.






        share|improve this answer








        New contributor



        Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.









        The answer is



        $ grep -v auto -m 1000 my_log_file.log > filtered_1000_lines.log


        Where -m NUM, --max-count is the maximum number of matched lines to stop the command, so the filtered_1000_lines.log will be feed with the first 1000 matched lines.







        share|improve this answer








        New contributor



        Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        share|improve this answer



        share|improve this answer






        New contributor



        Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.








        answered 37 mins ago









        Juan-KabbaliJuan-Kabbali

        12 bronze badges




        12 bronze badges




        New contributor



        Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.




        New contributor




        Juan-Kabbali is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
        Check out our Code of Conduct.



























            Juan-Kabbali is a new contributor. Be nice, and check out our Code of Conduct.










            draft saved

            draft discarded


















            Juan-Kabbali is a new contributor. Be nice, and check out our Code of Conduct.













            Juan-Kabbali is a new contributor. Be nice, and check out our Code of Conduct.












            Juan-Kabbali is a new contributor. Be nice, and check out our Code of Conduct.
















            Thanks for contributing an answer to Unix & Linux Stack Exchange!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f534256%2fgrep-only-a-given-number-of-lines-after-match%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            Taj Mahal Inhaltsverzeichnis Aufbau | Geschichte | 350-Jahr-Feier | Heutige Bedeutung | Siehe auch |...

            Baia Sprie Cuprins Etimologie | Istorie | Demografie | Politică și administrație | Arii naturale...

            Ciclooctatetraenă Vezi și | Bibliografie | Meniu de navigare637866text4148569-500570979m