why piping pwd and echo does not work? [duplicate]

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





.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty margin-bottom:0;







up vote
2
down vote

favorite













This question already has an answer here:



  • Why doesn't text piped into an echo get outputted? [duplicate]

    1 answer



  • Redirecting the content of a file to the command “echo”

    5 answers



I'm new to unix. I typed this command in ubuntu terminal:



pwd | echo


I expected to see the output of pwd in terminal(/home/fatemeh/Documents/Code/test)
but the output was just a single empty line.



why this happens?







share|improve this question











marked as duplicate by G-Man, Kusalananda, roaima, Community♦ Jul 27 at 15:26


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.




















    up vote
    2
    down vote

    favorite













    This question already has an answer here:



    • Why doesn't text piped into an echo get outputted? [duplicate]

      1 answer



    • Redirecting the content of a file to the command “echo”

      5 answers



    I'm new to unix. I typed this command in ubuntu terminal:



    pwd | echo


    I expected to see the output of pwd in terminal(/home/fatemeh/Documents/Code/test)
    but the output was just a single empty line.



    why this happens?







    share|improve this question











    marked as duplicate by G-Man, Kusalananda, roaima, Community♦ Jul 27 at 15:26


    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.
















      up vote
      2
      down vote

      favorite









      up vote
      2
      down vote

      favorite












      This question already has an answer here:



      • Why doesn't text piped into an echo get outputted? [duplicate]

        1 answer



      • Redirecting the content of a file to the command “echo”

        5 answers



      I'm new to unix. I typed this command in ubuntu terminal:



      pwd | echo


      I expected to see the output of pwd in terminal(/home/fatemeh/Documents/Code/test)
      but the output was just a single empty line.



      why this happens?







      share|improve this question












      This question already has an answer here:



      • Why doesn't text piped into an echo get outputted? [duplicate]

        1 answer



      • Redirecting the content of a file to the command “echo”

        5 answers



      I'm new to unix. I typed this command in ubuntu terminal:



      pwd | echo


      I expected to see the output of pwd in terminal(/home/fatemeh/Documents/Code/test)
      but the output was just a single empty line.



      why this happens?





      This question already has an answer here:



      • Why doesn't text piped into an echo get outputted? [duplicate]

        1 answer



      • Redirecting the content of a file to the command “echo”

        5 answers









      share|improve this question










      share|improve this question




      share|improve this question









      asked Jul 27 at 15:06









      Fatemeh Karimi

      1154




      1154




      marked as duplicate by G-Man, Kusalananda, roaima, Community♦ Jul 27 at 15:26


      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 G-Man, Kusalananda, roaima, Community♦ Jul 27 at 15:26


      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.






















          3 Answers
          3






          active

          oldest

          votes

















          up vote
          5
          down vote



          accepted










          echo does not do anything with standard input; it only parses its parameters. So you are effectively running echo which, by itself, outputs a single empty line, and the standard input is discarded.



          If you want to see the behavior you are trying to implement, use a tool designed to parse standard input, such as cat:



          $ pwd | cat
          /home/username


          If you really want to use echo to display the current working directory (or the output of another command), you can use Command Substitution to do this for you:



          $ echo "Your shell is currently working in '$(pwd)'."
          Your shell is currently working in '/home/username'.





          share|improve this answer






























            up vote
            2
            down vote













            As is stated in the other answers, echo does not read from stdin so it will not print the output of pwd. Just in case you don't know already, pwd prints it's output on it's own so you simply need to run it alone to get your desired result.



            $ pwd
            /current/working/dir


            If you really want to use echo for this you can use Command Substitution. This will pass the output of your command (pwd) to echo as a parameter. Which again in this example is not necessary as pwd will output it's own...output to stdout.



            $ echo "$(pwd)"
            /current/working/dir





            share|improve this answer




























              up vote
              1
              down vote













              The echo command doesn't read from standard input, it writes what you tell it to write. In this case, you didn't tell it to write anything, so all it printed was a newline. pwd | echo is equivalent to just running echo.



              If you want to use a pipe, then you need to use some command that reads from standard input (e.g., cat):



              $ pwd | cat
              /path/to/current/directory
              $





              share|improve this answer




























                3 Answers
                3






                active

                oldest

                votes








                3 Answers
                3






                active

                oldest

                votes









                active

                oldest

                votes






                active

                oldest

                votes








                up vote
                5
                down vote



                accepted










                echo does not do anything with standard input; it only parses its parameters. So you are effectively running echo which, by itself, outputs a single empty line, and the standard input is discarded.



                If you want to see the behavior you are trying to implement, use a tool designed to parse standard input, such as cat:



                $ pwd | cat
                /home/username


                If you really want to use echo to display the current working directory (or the output of another command), you can use Command Substitution to do this for you:



                $ echo "Your shell is currently working in '$(pwd)'."
                Your shell is currently working in '/home/username'.





                share|improve this answer



























                  up vote
                  5
                  down vote



                  accepted










                  echo does not do anything with standard input; it only parses its parameters. So you are effectively running echo which, by itself, outputs a single empty line, and the standard input is discarded.



                  If you want to see the behavior you are trying to implement, use a tool designed to parse standard input, such as cat:



                  $ pwd | cat
                  /home/username


                  If you really want to use echo to display the current working directory (or the output of another command), you can use Command Substitution to do this for you:



                  $ echo "Your shell is currently working in '$(pwd)'."
                  Your shell is currently working in '/home/username'.





                  share|improve this answer

























                    up vote
                    5
                    down vote



                    accepted







                    up vote
                    5
                    down vote



                    accepted






                    echo does not do anything with standard input; it only parses its parameters. So you are effectively running echo which, by itself, outputs a single empty line, and the standard input is discarded.



                    If you want to see the behavior you are trying to implement, use a tool designed to parse standard input, such as cat:



                    $ pwd | cat
                    /home/username


                    If you really want to use echo to display the current working directory (or the output of another command), you can use Command Substitution to do this for you:



                    $ echo "Your shell is currently working in '$(pwd)'."
                    Your shell is currently working in '/home/username'.





                    share|improve this answer















                    echo does not do anything with standard input; it only parses its parameters. So you are effectively running echo which, by itself, outputs a single empty line, and the standard input is discarded.



                    If you want to see the behavior you are trying to implement, use a tool designed to parse standard input, such as cat:



                    $ pwd | cat
                    /home/username


                    If you really want to use echo to display the current working directory (or the output of another command), you can use Command Substitution to do this for you:



                    $ echo "Your shell is currently working in '$(pwd)'."
                    Your shell is currently working in '/home/username'.






                    share|improve this answer















                    share|improve this answer



                    share|improve this answer








                    edited Jul 27 at 17:56


























                    answered Jul 27 at 15:08









                    DopeGhoti

                    39.5k54679




                    39.5k54679






















                        up vote
                        2
                        down vote













                        As is stated in the other answers, echo does not read from stdin so it will not print the output of pwd. Just in case you don't know already, pwd prints it's output on it's own so you simply need to run it alone to get your desired result.



                        $ pwd
                        /current/working/dir


                        If you really want to use echo for this you can use Command Substitution. This will pass the output of your command (pwd) to echo as a parameter. Which again in this example is not necessary as pwd will output it's own...output to stdout.



                        $ echo "$(pwd)"
                        /current/working/dir





                        share|improve this answer

























                          up vote
                          2
                          down vote













                          As is stated in the other answers, echo does not read from stdin so it will not print the output of pwd. Just in case you don't know already, pwd prints it's output on it's own so you simply need to run it alone to get your desired result.



                          $ pwd
                          /current/working/dir


                          If you really want to use echo for this you can use Command Substitution. This will pass the output of your command (pwd) to echo as a parameter. Which again in this example is not necessary as pwd will output it's own...output to stdout.



                          $ echo "$(pwd)"
                          /current/working/dir





                          share|improve this answer























                            up vote
                            2
                            down vote










                            up vote
                            2
                            down vote









                            As is stated in the other answers, echo does not read from stdin so it will not print the output of pwd. Just in case you don't know already, pwd prints it's output on it's own so you simply need to run it alone to get your desired result.



                            $ pwd
                            /current/working/dir


                            If you really want to use echo for this you can use Command Substitution. This will pass the output of your command (pwd) to echo as a parameter. Which again in this example is not necessary as pwd will output it's own...output to stdout.



                            $ echo "$(pwd)"
                            /current/working/dir





                            share|improve this answer













                            As is stated in the other answers, echo does not read from stdin so it will not print the output of pwd. Just in case you don't know already, pwd prints it's output on it's own so you simply need to run it alone to get your desired result.



                            $ pwd
                            /current/working/dir


                            If you really want to use echo for this you can use Command Substitution. This will pass the output of your command (pwd) to echo as a parameter. Which again in this example is not necessary as pwd will output it's own...output to stdout.



                            $ echo "$(pwd)"
                            /current/working/dir






                            share|improve this answer













                            share|improve this answer



                            share|improve this answer











                            answered Jul 27 at 15:14









                            Jesse_b

                            10.1k12658




                            10.1k12658




















                                up vote
                                1
                                down vote













                                The echo command doesn't read from standard input, it writes what you tell it to write. In this case, you didn't tell it to write anything, so all it printed was a newline. pwd | echo is equivalent to just running echo.



                                If you want to use a pipe, then you need to use some command that reads from standard input (e.g., cat):



                                $ pwd | cat
                                /path/to/current/directory
                                $





                                share|improve this answer

























                                  up vote
                                  1
                                  down vote













                                  The echo command doesn't read from standard input, it writes what you tell it to write. In this case, you didn't tell it to write anything, so all it printed was a newline. pwd | echo is equivalent to just running echo.



                                  If you want to use a pipe, then you need to use some command that reads from standard input (e.g., cat):



                                  $ pwd | cat
                                  /path/to/current/directory
                                  $





                                  share|improve this answer























                                    up vote
                                    1
                                    down vote










                                    up vote
                                    1
                                    down vote









                                    The echo command doesn't read from standard input, it writes what you tell it to write. In this case, you didn't tell it to write anything, so all it printed was a newline. pwd | echo is equivalent to just running echo.



                                    If you want to use a pipe, then you need to use some command that reads from standard input (e.g., cat):



                                    $ pwd | cat
                                    /path/to/current/directory
                                    $





                                    share|improve this answer













                                    The echo command doesn't read from standard input, it writes what you tell it to write. In this case, you didn't tell it to write anything, so all it printed was a newline. pwd | echo is equivalent to just running echo.



                                    If you want to use a pipe, then you need to use some command that reads from standard input (e.g., cat):



                                    $ pwd | cat
                                    /path/to/current/directory
                                    $






                                    share|improve this answer













                                    share|improve this answer



                                    share|improve this answer











                                    answered Jul 27 at 15:08









                                    Andy Dalton

                                    4,6911520




                                    4,6911520












                                        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