Where does pipe send its output?











up vote
0
down vote

favorite












My understanding is that pipe in e.g.,



command1 | command2 


sends the output of the command1 to command2. However, I would have expected this to work:



echo "tmp.pdf" | evince 


But it does not. Where is the output of echo "tmp.pdf" being sent?










share|improve this question




























    up vote
    0
    down vote

    favorite












    My understanding is that pipe in e.g.,



    command1 | command2 


    sends the output of the command1 to command2. However, I would have expected this to work:



    echo "tmp.pdf" | evince 


    But it does not. Where is the output of echo "tmp.pdf" being sent?










    share|improve this question


























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      My understanding is that pipe in e.g.,



      command1 | command2 


      sends the output of the command1 to command2. However, I would have expected this to work:



      echo "tmp.pdf" | evince 


      But it does not. Where is the output of echo "tmp.pdf" being sent?










      share|improve this question















      My understanding is that pipe in e.g.,



      command1 | command2 


      sends the output of the command1 to command2. However, I would have expected this to work:



      echo "tmp.pdf" | evince 


      But it does not. Where is the output of echo "tmp.pdf" being sent?







      pipe






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Nov 25 at 22:50









      Rui F Ribeiro

      38.3k1477127




      38.3k1477127










      asked Jun 29 '15 at 13:29









      JeffDror

      16016




      16016






















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          A pipe sends its output to the program that has it open for reading. In a shell pipeline, that's the program on the right-hand side of the pipe symbol, i.e. evince in your example.



          You're sending the file name tmp.pdf to evince on its standard input. However evince doesn't care about its standard input. Like every program that acts on a file, it expects the file name to be passed as a command line argument; if you don't pass a file name on the command line, it offers to open a file. Command line arguments are not the same thing as standard input. Humans have different input organs that input different things (e.g. you can't eat through your nose), and similarly programs have different ways of receiving information that serve different purposes.



          Evince can read a file (not a file name) on standard input: evince /dev/stdin <"tmp.pdf". (This may not work on all Unix variants.) The file name /dev/stdin means “whatever file you already have open on your standard input”. Programs intended for command line typically read their standard input when they aren't given a file name, but GUI programs usually don't. Evince can only open a regular file this way, not data from a pipe (e.g. cat tmp.pdf | evince /dev/stdin doesn't work), because it needs to be able to seek back and forth in the file when navigating between pages.






          share|improve this answer




























            up vote
            6
            down vote













            Your understanding is correct. The sequence command1 | command2 is sending the output (STDOUT) of command1 to the input (STDIN) of command2. The reason your evince command didn't work is that evince doesn't accept a filename on STDIN.






            share|improve this answer




























              up vote
              0
              down vote













              You can by pass this problem as follows as I lately realized on my own. First use locate command to find the path of the file that you wish to open in evince.Then Pass this result as argument in evince.Lets say your file name is abc_xyz.pdf and you wish to open it. Then you can do-
              evince "$(sudo locate xyz | grep abc)".
              Kindly note that in case the name of your pdf file contains spaces then you need to double quote the $(sudo locate xyz | grep abc)
              The reason why I am using another code (piped with sudo locate xyz) i.e grep abc is to further filter down the result.
              But here is a catch and that is,you need to constantly update the locate by issuing sudo updatedb. Lets say you changed the location of your pdf to some new directory then locate wont be able to find itz new location as itz data base hasnt been updated. But you can use "find" command with "and" condition to get your job done as it searches in real time.
              For instance you can do-



              evince "$(find ~/ -iname "*abc*" -a -iname "*xyz*" -type f)"


              and pass this as an argument to evince.here argument -iname is for case insensitive search and -a is and condition. -type f will only return files.






              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',
                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%2f212848%2fwhere-does-pipe-send-its-output%23new-answer', 'question_page');
                }
                );

                Post as a guest















                Required, but never shown

























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                5
                down vote



                accepted










                A pipe sends its output to the program that has it open for reading. In a shell pipeline, that's the program on the right-hand side of the pipe symbol, i.e. evince in your example.



                You're sending the file name tmp.pdf to evince on its standard input. However evince doesn't care about its standard input. Like every program that acts on a file, it expects the file name to be passed as a command line argument; if you don't pass a file name on the command line, it offers to open a file. Command line arguments are not the same thing as standard input. Humans have different input organs that input different things (e.g. you can't eat through your nose), and similarly programs have different ways of receiving information that serve different purposes.



                Evince can read a file (not a file name) on standard input: evince /dev/stdin <"tmp.pdf". (This may not work on all Unix variants.) The file name /dev/stdin means “whatever file you already have open on your standard input”. Programs intended for command line typically read their standard input when they aren't given a file name, but GUI programs usually don't. Evince can only open a regular file this way, not data from a pipe (e.g. cat tmp.pdf | evince /dev/stdin doesn't work), because it needs to be able to seek back and forth in the file when navigating between pages.






                share|improve this answer

























                  up vote
                  5
                  down vote



                  accepted










                  A pipe sends its output to the program that has it open for reading. In a shell pipeline, that's the program on the right-hand side of the pipe symbol, i.e. evince in your example.



                  You're sending the file name tmp.pdf to evince on its standard input. However evince doesn't care about its standard input. Like every program that acts on a file, it expects the file name to be passed as a command line argument; if you don't pass a file name on the command line, it offers to open a file. Command line arguments are not the same thing as standard input. Humans have different input organs that input different things (e.g. you can't eat through your nose), and similarly programs have different ways of receiving information that serve different purposes.



                  Evince can read a file (not a file name) on standard input: evince /dev/stdin <"tmp.pdf". (This may not work on all Unix variants.) The file name /dev/stdin means “whatever file you already have open on your standard input”. Programs intended for command line typically read their standard input when they aren't given a file name, but GUI programs usually don't. Evince can only open a regular file this way, not data from a pipe (e.g. cat tmp.pdf | evince /dev/stdin doesn't work), because it needs to be able to seek back and forth in the file when navigating between pages.






                  share|improve this answer























                    up vote
                    5
                    down vote



                    accepted







                    up vote
                    5
                    down vote



                    accepted






                    A pipe sends its output to the program that has it open for reading. In a shell pipeline, that's the program on the right-hand side of the pipe symbol, i.e. evince in your example.



                    You're sending the file name tmp.pdf to evince on its standard input. However evince doesn't care about its standard input. Like every program that acts on a file, it expects the file name to be passed as a command line argument; if you don't pass a file name on the command line, it offers to open a file. Command line arguments are not the same thing as standard input. Humans have different input organs that input different things (e.g. you can't eat through your nose), and similarly programs have different ways of receiving information that serve different purposes.



                    Evince can read a file (not a file name) on standard input: evince /dev/stdin <"tmp.pdf". (This may not work on all Unix variants.) The file name /dev/stdin means “whatever file you already have open on your standard input”. Programs intended for command line typically read their standard input when they aren't given a file name, but GUI programs usually don't. Evince can only open a regular file this way, not data from a pipe (e.g. cat tmp.pdf | evince /dev/stdin doesn't work), because it needs to be able to seek back and forth in the file when navigating between pages.






                    share|improve this answer












                    A pipe sends its output to the program that has it open for reading. In a shell pipeline, that's the program on the right-hand side of the pipe symbol, i.e. evince in your example.



                    You're sending the file name tmp.pdf to evince on its standard input. However evince doesn't care about its standard input. Like every program that acts on a file, it expects the file name to be passed as a command line argument; if you don't pass a file name on the command line, it offers to open a file. Command line arguments are not the same thing as standard input. Humans have different input organs that input different things (e.g. you can't eat through your nose), and similarly programs have different ways of receiving information that serve different purposes.



                    Evince can read a file (not a file name) on standard input: evince /dev/stdin <"tmp.pdf". (This may not work on all Unix variants.) The file name /dev/stdin means “whatever file you already have open on your standard input”. Programs intended for command line typically read their standard input when they aren't given a file name, but GUI programs usually don't. Evince can only open a regular file this way, not data from a pipe (e.g. cat tmp.pdf | evince /dev/stdin doesn't work), because it needs to be able to seek back and forth in the file when navigating between pages.







                    share|improve this answer












                    share|improve this answer



                    share|improve this answer










                    answered Jun 29 '15 at 23:49









                    Gilles

                    523k12610441576




                    523k12610441576
























                        up vote
                        6
                        down vote













                        Your understanding is correct. The sequence command1 | command2 is sending the output (STDOUT) of command1 to the input (STDIN) of command2. The reason your evince command didn't work is that evince doesn't accept a filename on STDIN.






                        share|improve this answer

























                          up vote
                          6
                          down vote













                          Your understanding is correct. The sequence command1 | command2 is sending the output (STDOUT) of command1 to the input (STDIN) of command2. The reason your evince command didn't work is that evince doesn't accept a filename on STDIN.






                          share|improve this answer























                            up vote
                            6
                            down vote










                            up vote
                            6
                            down vote









                            Your understanding is correct. The sequence command1 | command2 is sending the output (STDOUT) of command1 to the input (STDIN) of command2. The reason your evince command didn't work is that evince doesn't accept a filename on STDIN.






                            share|improve this answer












                            Your understanding is correct. The sequence command1 | command2 is sending the output (STDOUT) of command1 to the input (STDIN) of command2. The reason your evince command didn't work is that evince doesn't accept a filename on STDIN.







                            share|improve this answer












                            share|improve this answer



                            share|improve this answer










                            answered Jun 29 '15 at 13:31









                            John

                            11.4k11730




                            11.4k11730






















                                up vote
                                0
                                down vote













                                You can by pass this problem as follows as I lately realized on my own. First use locate command to find the path of the file that you wish to open in evince.Then Pass this result as argument in evince.Lets say your file name is abc_xyz.pdf and you wish to open it. Then you can do-
                                evince "$(sudo locate xyz | grep abc)".
                                Kindly note that in case the name of your pdf file contains spaces then you need to double quote the $(sudo locate xyz | grep abc)
                                The reason why I am using another code (piped with sudo locate xyz) i.e grep abc is to further filter down the result.
                                But here is a catch and that is,you need to constantly update the locate by issuing sudo updatedb. Lets say you changed the location of your pdf to some new directory then locate wont be able to find itz new location as itz data base hasnt been updated. But you can use "find" command with "and" condition to get your job done as it searches in real time.
                                For instance you can do-



                                evince "$(find ~/ -iname "*abc*" -a -iname "*xyz*" -type f)"


                                and pass this as an argument to evince.here argument -iname is for case insensitive search and -a is and condition. -type f will only return files.






                                share|improve this answer



























                                  up vote
                                  0
                                  down vote













                                  You can by pass this problem as follows as I lately realized on my own. First use locate command to find the path of the file that you wish to open in evince.Then Pass this result as argument in evince.Lets say your file name is abc_xyz.pdf and you wish to open it. Then you can do-
                                  evince "$(sudo locate xyz | grep abc)".
                                  Kindly note that in case the name of your pdf file contains spaces then you need to double quote the $(sudo locate xyz | grep abc)
                                  The reason why I am using another code (piped with sudo locate xyz) i.e grep abc is to further filter down the result.
                                  But here is a catch and that is,you need to constantly update the locate by issuing sudo updatedb. Lets say you changed the location of your pdf to some new directory then locate wont be able to find itz new location as itz data base hasnt been updated. But you can use "find" command with "and" condition to get your job done as it searches in real time.
                                  For instance you can do-



                                  evince "$(find ~/ -iname "*abc*" -a -iname "*xyz*" -type f)"


                                  and pass this as an argument to evince.here argument -iname is for case insensitive search and -a is and condition. -type f will only return files.






                                  share|improve this answer

























                                    up vote
                                    0
                                    down vote










                                    up vote
                                    0
                                    down vote









                                    You can by pass this problem as follows as I lately realized on my own. First use locate command to find the path of the file that you wish to open in evince.Then Pass this result as argument in evince.Lets say your file name is abc_xyz.pdf and you wish to open it. Then you can do-
                                    evince "$(sudo locate xyz | grep abc)".
                                    Kindly note that in case the name of your pdf file contains spaces then you need to double quote the $(sudo locate xyz | grep abc)
                                    The reason why I am using another code (piped with sudo locate xyz) i.e grep abc is to further filter down the result.
                                    But here is a catch and that is,you need to constantly update the locate by issuing sudo updatedb. Lets say you changed the location of your pdf to some new directory then locate wont be able to find itz new location as itz data base hasnt been updated. But you can use "find" command with "and" condition to get your job done as it searches in real time.
                                    For instance you can do-



                                    evince "$(find ~/ -iname "*abc*" -a -iname "*xyz*" -type f)"


                                    and pass this as an argument to evince.here argument -iname is for case insensitive search and -a is and condition. -type f will only return files.






                                    share|improve this answer














                                    You can by pass this problem as follows as I lately realized on my own. First use locate command to find the path of the file that you wish to open in evince.Then Pass this result as argument in evince.Lets say your file name is abc_xyz.pdf and you wish to open it. Then you can do-
                                    evince "$(sudo locate xyz | grep abc)".
                                    Kindly note that in case the name of your pdf file contains spaces then you need to double quote the $(sudo locate xyz | grep abc)
                                    The reason why I am using another code (piped with sudo locate xyz) i.e grep abc is to further filter down the result.
                                    But here is a catch and that is,you need to constantly update the locate by issuing sudo updatedb. Lets say you changed the location of your pdf to some new directory then locate wont be able to find itz new location as itz data base hasnt been updated. But you can use "find" command with "and" condition to get your job done as it searches in real time.
                                    For instance you can do-



                                    evince "$(find ~/ -iname "*abc*" -a -iname "*xyz*" -type f)"


                                    and pass this as an argument to evince.here argument -iname is for case insensitive search and -a is and condition. -type f will only return files.







                                    share|improve this answer














                                    share|improve this answer



                                    share|improve this answer








                                    edited Dec 17 '16 at 3:55

























                                    answered Dec 16 '16 at 10:52









                                    Amardeep Mishra

                                    12




                                    12






























                                        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.





                                        Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


                                        Please pay close attention to the following guidance:


                                        • 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%2f212848%2fwhere-does-pipe-send-its-output%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

                                        Morgemoulin

                                        Scott Moir

                                        Souastre