Go to line of file where number of lines minus “n” [duplicate]

Multi tool use
Multi tool use

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











up vote
0
down vote

favorite













This question already has an answer here:



  • Display only the penultimate (second last) row of a text [duplicate]

    5 answers



Say I want to go to the 80th last line of my file celery.log, but I don't know how many lines it has.



The equivalent of the tail command but go to the 80th line from the end instead of the default.



How would I do this?







share|improve this question













marked as duplicate by Kusalananda, αғsнιη, Jeff Schaller, Satō Katsura, Kiwy May 9 at 7:42


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.










  • 2




    What do you mean by "go to"?
    – Kusalananda
    May 8 at 7:26










  • The equivilant of tail command but go to the 80th last line instead of the default.
    – Zorgan
    May 8 at 7:27






  • 4




    like tail -n80 celery.log ?
    – Charles
    May 8 at 7:29











  • @Charles yes that's perfect. thanks!
    – Zorgan
    May 8 at 8:26














up vote
0
down vote

favorite













This question already has an answer here:



  • Display only the penultimate (second last) row of a text [duplicate]

    5 answers



Say I want to go to the 80th last line of my file celery.log, but I don't know how many lines it has.



The equivalent of the tail command but go to the 80th line from the end instead of the default.



How would I do this?







share|improve this question













marked as duplicate by Kusalananda, αғsнιη, Jeff Schaller, Satō Katsura, Kiwy May 9 at 7:42


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.










  • 2




    What do you mean by "go to"?
    – Kusalananda
    May 8 at 7:26










  • The equivilant of tail command but go to the 80th last line instead of the default.
    – Zorgan
    May 8 at 7:27






  • 4




    like tail -n80 celery.log ?
    – Charles
    May 8 at 7:29











  • @Charles yes that's perfect. thanks!
    – Zorgan
    May 8 at 8:26












up vote
0
down vote

favorite









up vote
0
down vote

favorite












This question already has an answer here:



  • Display only the penultimate (second last) row of a text [duplicate]

    5 answers



Say I want to go to the 80th last line of my file celery.log, but I don't know how many lines it has.



The equivalent of the tail command but go to the 80th line from the end instead of the default.



How would I do this?







share|improve this question














This question already has an answer here:



  • Display only the penultimate (second last) row of a text [duplicate]

    5 answers



Say I want to go to the 80th last line of my file celery.log, but I don't know how many lines it has.



The equivalent of the tail command but go to the 80th line from the end instead of the default.



How would I do this?





This question already has an answer here:



  • Display only the penultimate (second last) row of a text [duplicate]

    5 answers









share|improve this question












share|improve this question




share|improve this question








edited May 8 at 7:43









roaima

39.4k544105




39.4k544105









asked May 8 at 7:20









Zorgan

1104




1104




marked as duplicate by Kusalananda, αғsнιη, Jeff Schaller, Satō Katsura, Kiwy May 9 at 7:42


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 Kusalananda, αғsнιη, Jeff Schaller, Satō Katsura, Kiwy May 9 at 7:42


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.









  • 2




    What do you mean by "go to"?
    – Kusalananda
    May 8 at 7:26










  • The equivilant of tail command but go to the 80th last line instead of the default.
    – Zorgan
    May 8 at 7:27






  • 4




    like tail -n80 celery.log ?
    – Charles
    May 8 at 7:29











  • @Charles yes that's perfect. thanks!
    – Zorgan
    May 8 at 8:26












  • 2




    What do you mean by "go to"?
    – Kusalananda
    May 8 at 7:26










  • The equivilant of tail command but go to the 80th last line instead of the default.
    – Zorgan
    May 8 at 7:27






  • 4




    like tail -n80 celery.log ?
    – Charles
    May 8 at 7:29











  • @Charles yes that's perfect. thanks!
    – Zorgan
    May 8 at 8:26







2




2




What do you mean by "go to"?
– Kusalananda
May 8 at 7:26




What do you mean by "go to"?
– Kusalananda
May 8 at 7:26












The equivilant of tail command but go to the 80th last line instead of the default.
– Zorgan
May 8 at 7:27




The equivilant of tail command but go to the 80th last line instead of the default.
– Zorgan
May 8 at 7:27




4




4




like tail -n80 celery.log ?
– Charles
May 8 at 7:29





like tail -n80 celery.log ?
– Charles
May 8 at 7:29













@Charles yes that's perfect. thanks!
– Zorgan
May 8 at 8:26




@Charles yes that's perfect. thanks!
– Zorgan
May 8 at 8:26










3 Answers
3






active

oldest

votes

















up vote
3
down vote













echo '$-79p' | ed -s celery.log


This would run the ed script $-79p on the file called celery.log, which would display the line that is 79 lines up from the last line of the file.



In a shell that understands here-strings:



ed -s celery.log <<<'$-79p'


If the file has less than 80 lines, ed will return an error (the character ? on its standard error stream) and produce no output on the standard output stream.






share|improve this answer






























    up vote
    2
    down vote













    tail -n 80 celery.log | head -n 1


    This will show the first of the last 80 lines (if the file has fewer than 80 lines, it will show the first line of the file).






    share|improve this answer






























      up vote
      1
      down vote













      Yo can do this:



      tac celery.log | sed -n '80p'





      share|improve this answer




























        3 Answers
        3






        active

        oldest

        votes








        3 Answers
        3






        active

        oldest

        votes









        active

        oldest

        votes






        active

        oldest

        votes








        up vote
        3
        down vote













        echo '$-79p' | ed -s celery.log


        This would run the ed script $-79p on the file called celery.log, which would display the line that is 79 lines up from the last line of the file.



        In a shell that understands here-strings:



        ed -s celery.log <<<'$-79p'


        If the file has less than 80 lines, ed will return an error (the character ? on its standard error stream) and produce no output on the standard output stream.






        share|improve this answer



























          up vote
          3
          down vote













          echo '$-79p' | ed -s celery.log


          This would run the ed script $-79p on the file called celery.log, which would display the line that is 79 lines up from the last line of the file.



          In a shell that understands here-strings:



          ed -s celery.log <<<'$-79p'


          If the file has less than 80 lines, ed will return an error (the character ? on its standard error stream) and produce no output on the standard output stream.






          share|improve this answer

























            up vote
            3
            down vote










            up vote
            3
            down vote









            echo '$-79p' | ed -s celery.log


            This would run the ed script $-79p on the file called celery.log, which would display the line that is 79 lines up from the last line of the file.



            In a shell that understands here-strings:



            ed -s celery.log <<<'$-79p'


            If the file has less than 80 lines, ed will return an error (the character ? on its standard error stream) and produce no output on the standard output stream.






            share|improve this answer















            echo '$-79p' | ed -s celery.log


            This would run the ed script $-79p on the file called celery.log, which would display the line that is 79 lines up from the last line of the file.



            In a shell that understands here-strings:



            ed -s celery.log <<<'$-79p'


            If the file has less than 80 lines, ed will return an error (the character ? on its standard error stream) and produce no output on the standard output stream.







            share|improve this answer















            share|improve this answer



            share|improve this answer








            edited May 8 at 8:40


























            answered May 8 at 7:42









            Kusalananda

            102k13199315




            102k13199315






















                up vote
                2
                down vote













                tail -n 80 celery.log | head -n 1


                This will show the first of the last 80 lines (if the file has fewer than 80 lines, it will show the first line of the file).






                share|improve this answer



























                  up vote
                  2
                  down vote













                  tail -n 80 celery.log | head -n 1


                  This will show the first of the last 80 lines (if the file has fewer than 80 lines, it will show the first line of the file).






                  share|improve this answer

























                    up vote
                    2
                    down vote










                    up vote
                    2
                    down vote









                    tail -n 80 celery.log | head -n 1


                    This will show the first of the last 80 lines (if the file has fewer than 80 lines, it will show the first line of the file).






                    share|improve this answer















                    tail -n 80 celery.log | head -n 1


                    This will show the first of the last 80 lines (if the file has fewer than 80 lines, it will show the first line of the file).







                    share|improve this answer















                    share|improve this answer



                    share|improve this answer








                    edited May 8 at 8:20









                    Stéphane Chazelas

                    279k53514845




                    279k53514845











                    answered May 8 at 7:35









                    Kyrie001

                    434




                    434




















                        up vote
                        1
                        down vote













                        Yo can do this:



                        tac celery.log | sed -n '80p'





                        share|improve this answer

























                          up vote
                          1
                          down vote













                          Yo can do this:



                          tac celery.log | sed -n '80p'





                          share|improve this answer























                            up vote
                            1
                            down vote










                            up vote
                            1
                            down vote









                            Yo can do this:



                            tac celery.log | sed -n '80p'





                            share|improve this answer













                            Yo can do this:



                            tac celery.log | sed -n '80p'






                            share|improve this answer













                            share|improve this answer



                            share|improve this answer











                            answered May 8 at 7:38









                            matsib.dev

                            14613




                            14613












                                K,5YE9ojaOOIwD0PzRegsb07,OywWlXk,jSVbMm1t7E6mM,RR3Ds,ydRxj FOLPfL v9w8E4HII,1vHsstWQ3InrKULYT9g8uLXoS4s
                                YES ZbYM LK9Aq piA3B,vMs cxeXLovc

                                Popular posts from this blog

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

                                How many registers does an x86_64 CPU actually have?

                                Displaying single band from multi-band raster using QGIS