Filter screenlog with screen command

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












1















Pressing Ctrl+A, H, lets me log output of the screen command. However, the output file is too large.
Is it possible to apply a grep-like filter so that I can control what gets logged?



For example, I might wish to log only lines which contain the phrase foo bar.










share|improve this question




























    1















    Pressing Ctrl+A, H, lets me log output of the screen command. However, the output file is too large.
    Is it possible to apply a grep-like filter so that I can control what gets logged?



    For example, I might wish to log only lines which contain the phrase foo bar.










    share|improve this question


























      1












      1








      1








      Pressing Ctrl+A, H, lets me log output of the screen command. However, the output file is too large.
      Is it possible to apply a grep-like filter so that I can control what gets logged?



      For example, I might wish to log only lines which contain the phrase foo bar.










      share|improve this question
















      Pressing Ctrl+A, H, lets me log output of the screen command. However, the output file is too large.
      Is it possible to apply a grep-like filter so that I can control what gets logged?



      For example, I might wish to log only lines which contain the phrase foo bar.







      grep gnu-screen






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jul 2 '15 at 12:39









      G-Man

      13.6k93768




      13.6k93768










      asked Jul 2 '15 at 12:10









      curryagecurryage

      1063




      1063




















          1 Answer
          1






          active

          oldest

          votes


















          0














          Interesting question. I just skimmed through man screen so I am not absolutely sure whether it is possible to achieve without using external tools. However, one can use a named pipe and a combination of tail and grep to do this:



          $ mkfifo /tmp/fifo/fifo
          $ tail -f /tmp/fifo/fifo | grep --line-buffered bar >> /tmp/DONE


          Inside screen do:



          logfile /tmp/fifo/fifo


          and start logging. After finishing logging only lines that contained bar will be saved in /tmp/DONE. As it states in man fifo:




          A FIFO special file (a named pipe) is similar to a pipe, except that
          it is accessed as part of the file system. It can be opened by
          multiple processes for reading or writ- ing. When processes are
          exchanging data via the FIFO, the kernel passes all data internally
          without writing it to the file system. Thus, the FIFO special file has
          no con- tents on the file system; the file system entry merely serves
          as a reference point so that processes can access the pipe using a
          name in the file system.




          That means that /tmp/fifo/fifo takes no space on disk. This solution worked for me but I don't know what negative side-effects or shortcomings it may have.



          EDIT:



          I just noticed that they recommend using fifo in man script:




          -f, --flush Flush output after each write. This is nice for telecooperation: one person does 'mkfifo foo; script -f foo', and
          another can supervise real-time what is being done using 'cat foo'.




          In case you didn't know, script is an utility that also records terminal session.






          share|improve this answer
























            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
            );



            );













            draft saved

            draft discarded


















            StackExchange.ready(
            function ()
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2funix.stackexchange.com%2fquestions%2f213516%2ffilter-screenlog-with-screen-command%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














            Interesting question. I just skimmed through man screen so I am not absolutely sure whether it is possible to achieve without using external tools. However, one can use a named pipe and a combination of tail and grep to do this:



            $ mkfifo /tmp/fifo/fifo
            $ tail -f /tmp/fifo/fifo | grep --line-buffered bar >> /tmp/DONE


            Inside screen do:



            logfile /tmp/fifo/fifo


            and start logging. After finishing logging only lines that contained bar will be saved in /tmp/DONE. As it states in man fifo:




            A FIFO special file (a named pipe) is similar to a pipe, except that
            it is accessed as part of the file system. It can be opened by
            multiple processes for reading or writ- ing. When processes are
            exchanging data via the FIFO, the kernel passes all data internally
            without writing it to the file system. Thus, the FIFO special file has
            no con- tents on the file system; the file system entry merely serves
            as a reference point so that processes can access the pipe using a
            name in the file system.




            That means that /tmp/fifo/fifo takes no space on disk. This solution worked for me but I don't know what negative side-effects or shortcomings it may have.



            EDIT:



            I just noticed that they recommend using fifo in man script:




            -f, --flush Flush output after each write. This is nice for telecooperation: one person does 'mkfifo foo; script -f foo', and
            another can supervise real-time what is being done using 'cat foo'.




            In case you didn't know, script is an utility that also records terminal session.






            share|improve this answer





























              0














              Interesting question. I just skimmed through man screen so I am not absolutely sure whether it is possible to achieve without using external tools. However, one can use a named pipe and a combination of tail and grep to do this:



              $ mkfifo /tmp/fifo/fifo
              $ tail -f /tmp/fifo/fifo | grep --line-buffered bar >> /tmp/DONE


              Inside screen do:



              logfile /tmp/fifo/fifo


              and start logging. After finishing logging only lines that contained bar will be saved in /tmp/DONE. As it states in man fifo:




              A FIFO special file (a named pipe) is similar to a pipe, except that
              it is accessed as part of the file system. It can be opened by
              multiple processes for reading or writ- ing. When processes are
              exchanging data via the FIFO, the kernel passes all data internally
              without writing it to the file system. Thus, the FIFO special file has
              no con- tents on the file system; the file system entry merely serves
              as a reference point so that processes can access the pipe using a
              name in the file system.




              That means that /tmp/fifo/fifo takes no space on disk. This solution worked for me but I don't know what negative side-effects or shortcomings it may have.



              EDIT:



              I just noticed that they recommend using fifo in man script:




              -f, --flush Flush output after each write. This is nice for telecooperation: one person does 'mkfifo foo; script -f foo', and
              another can supervise real-time what is being done using 'cat foo'.




              In case you didn't know, script is an utility that also records terminal session.






              share|improve this answer



























                0












                0








                0







                Interesting question. I just skimmed through man screen so I am not absolutely sure whether it is possible to achieve without using external tools. However, one can use a named pipe and a combination of tail and grep to do this:



                $ mkfifo /tmp/fifo/fifo
                $ tail -f /tmp/fifo/fifo | grep --line-buffered bar >> /tmp/DONE


                Inside screen do:



                logfile /tmp/fifo/fifo


                and start logging. After finishing logging only lines that contained bar will be saved in /tmp/DONE. As it states in man fifo:




                A FIFO special file (a named pipe) is similar to a pipe, except that
                it is accessed as part of the file system. It can be opened by
                multiple processes for reading or writ- ing. When processes are
                exchanging data via the FIFO, the kernel passes all data internally
                without writing it to the file system. Thus, the FIFO special file has
                no con- tents on the file system; the file system entry merely serves
                as a reference point so that processes can access the pipe using a
                name in the file system.




                That means that /tmp/fifo/fifo takes no space on disk. This solution worked for me but I don't know what negative side-effects or shortcomings it may have.



                EDIT:



                I just noticed that they recommend using fifo in man script:




                -f, --flush Flush output after each write. This is nice for telecooperation: one person does 'mkfifo foo; script -f foo', and
                another can supervise real-time what is being done using 'cat foo'.




                In case you didn't know, script is an utility that also records terminal session.






                share|improve this answer















                Interesting question. I just skimmed through man screen so I am not absolutely sure whether it is possible to achieve without using external tools. However, one can use a named pipe and a combination of tail and grep to do this:



                $ mkfifo /tmp/fifo/fifo
                $ tail -f /tmp/fifo/fifo | grep --line-buffered bar >> /tmp/DONE


                Inside screen do:



                logfile /tmp/fifo/fifo


                and start logging. After finishing logging only lines that contained bar will be saved in /tmp/DONE. As it states in man fifo:




                A FIFO special file (a named pipe) is similar to a pipe, except that
                it is accessed as part of the file system. It can be opened by
                multiple processes for reading or writ- ing. When processes are
                exchanging data via the FIFO, the kernel passes all data internally
                without writing it to the file system. Thus, the FIFO special file has
                no con- tents on the file system; the file system entry merely serves
                as a reference point so that processes can access the pipe using a
                name in the file system.




                That means that /tmp/fifo/fifo takes no space on disk. This solution worked for me but I don't know what negative side-effects or shortcomings it may have.



                EDIT:



                I just noticed that they recommend using fifo in man script:




                -f, --flush Flush output after each write. This is nice for telecooperation: one person does 'mkfifo foo; script -f foo', and
                another can supervise real-time what is being done using 'cat foo'.




                In case you didn't know, script is an utility that also records terminal session.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited Jul 2 '15 at 17:41

























                answered Jul 2 '15 at 17:34









                Arkadiusz DrabczykArkadiusz Drabczyk

                8,30521836




                8,30521836



























                    draft saved

                    draft discarded
















































                    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%2f213516%2ffilter-screenlog-with-screen-command%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

                    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?