Split echo's output on two lines

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








up vote
-2
down vote

favorite












It is written in the manual that /n will split the output of echo command to the next line. I tried:



echo -e 'hello /n world'
hello /n world


Expecting 'world' on the next line. I failed.










share|improve this question



















  • 4




    In which manual is it written that /n will do that?
    – muru
    Mar 15 at 12:02














up vote
-2
down vote

favorite












It is written in the manual that /n will split the output of echo command to the next line. I tried:



echo -e 'hello /n world'
hello /n world


Expecting 'world' on the next line. I failed.










share|improve this question



















  • 4




    In which manual is it written that /n will do that?
    – muru
    Mar 15 at 12:02












up vote
-2
down vote

favorite









up vote
-2
down vote

favorite











It is written in the manual that /n will split the output of echo command to the next line. I tried:



echo -e 'hello /n world'
hello /n world


Expecting 'world' on the next line. I failed.










share|improve this question















It is written in the manual that /n will split the output of echo command to the next line. I tried:



echo -e 'hello /n world'
hello /n world


Expecting 'world' on the next line. I failed.







command-line echo






share|improve this question















share|improve this question













share|improve this question




share|improve this question








edited Mar 15 at 13:19









Melebius

3,81341636




3,81341636










asked Mar 15 at 11:41









Josef Klimuk

542112




542112







  • 4




    In which manual is it written that /n will do that?
    – muru
    Mar 15 at 12:02












  • 4




    In which manual is it written that /n will do that?
    – muru
    Mar 15 at 12:02







4




4




In which manual is it written that /n will do that?
– muru
Mar 15 at 12:02




In which manual is it written that /n will do that?
– muru
Mar 15 at 12:02










4 Answers
4






active

oldest

votes

















up vote
10
down vote



accepted










Your mistake is to use /n instead of n.



So just try echo -e 'hello nworld' and you will get what you expect.



Notice that I have removed the space between n and world. Else the second line will start with a space.






share|improve this answer





























    up vote
    3
    down vote













    n is new line not /n



    You should try this:



    echo -e 'hello n world'





    share|improve this answer



























      up vote
      2
      down vote













      From man echo:



       -e enable interpretation of backslash escapes

      -E disable interpretation of backslash escapes (default)

      If -e is in effect, the following sequences are recognized:

      \ backslash

      a alert (BEL)

      b backspace

      c produce no further output

      e escape

      f form feed

      n new line

      r carriage return

      t horizontal tab

      v vertical tab

      NNN byte with octal value NNN (1 to 3 digits)

      xHH byte with hexadecimal value HH (1 to 2 digits)

      NOTE: your shell may have its own version of echo, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.


      Please note the NOTE :) For example in sh there is no option -e for echo:



      $ sh -c "echo -e 'hello n world'"
      -e hello
      world


      You can see -e is output as regular text but the backslash escape is interpreted as it is expected.






      share|improve this answer



























        up vote
        1
        down vote













        A straight-forward alternative is to use manifest line feeds in the quoted string,



        echo "hello
        world"


        If you want to see the alignment, press enter after the first quotation character



        echo "
        hello beautiful
        wonderful world"


        and remove that line feed to avoid a blank first line of the output.






        share|improve this answer




















          Your Answer







          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "89"
          ;
          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: true,
          noModals: false,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













           

          draft saved


          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1015151%2fsplit-echos-output-on-two-lines%23new-answer', 'question_page');

          );

          Post as a guest






























          4 Answers
          4






          active

          oldest

          votes








          4 Answers
          4






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes








          up vote
          10
          down vote



          accepted










          Your mistake is to use /n instead of n.



          So just try echo -e 'hello nworld' and you will get what you expect.



          Notice that I have removed the space between n and world. Else the second line will start with a space.






          share|improve this answer


























            up vote
            10
            down vote



            accepted










            Your mistake is to use /n instead of n.



            So just try echo -e 'hello nworld' and you will get what you expect.



            Notice that I have removed the space between n and world. Else the second line will start with a space.






            share|improve this answer
























              up vote
              10
              down vote



              accepted







              up vote
              10
              down vote



              accepted






              Your mistake is to use /n instead of n.



              So just try echo -e 'hello nworld' and you will get what you expect.



              Notice that I have removed the space between n and world. Else the second line will start with a space.






              share|improve this answer














              Your mistake is to use /n instead of n.



              So just try echo -e 'hello nworld' and you will get what you expect.



              Notice that I have removed the space between n and world. Else the second line will start with a space.







              share|improve this answer














              share|improve this answer



              share|improve this answer








              edited Mar 15 at 13:21









              Melebius

              3,81341636




              3,81341636










              answered Mar 15 at 11:46









              rebrec

              1816




              1816






















                  up vote
                  3
                  down vote













                  n is new line not /n



                  You should try this:



                  echo -e 'hello n world'





                  share|improve this answer
























                    up vote
                    3
                    down vote













                    n is new line not /n



                    You should try this:



                    echo -e 'hello n world'





                    share|improve this answer






















                      up vote
                      3
                      down vote










                      up vote
                      3
                      down vote









                      n is new line not /n



                      You should try this:



                      echo -e 'hello n world'





                      share|improve this answer












                      n is new line not /n



                      You should try this:



                      echo -e 'hello n world'






                      share|improve this answer












                      share|improve this answer



                      share|improve this answer










                      answered Mar 15 at 11:45









                      Goran Vrbaški

                      31616




                      31616




















                          up vote
                          2
                          down vote













                          From man echo:



                           -e enable interpretation of backslash escapes

                          -E disable interpretation of backslash escapes (default)

                          If -e is in effect, the following sequences are recognized:

                          \ backslash

                          a alert (BEL)

                          b backspace

                          c produce no further output

                          e escape

                          f form feed

                          n new line

                          r carriage return

                          t horizontal tab

                          v vertical tab

                          NNN byte with octal value NNN (1 to 3 digits)

                          xHH byte with hexadecimal value HH (1 to 2 digits)

                          NOTE: your shell may have its own version of echo, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.


                          Please note the NOTE :) For example in sh there is no option -e for echo:



                          $ sh -c "echo -e 'hello n world'"
                          -e hello
                          world


                          You can see -e is output as regular text but the backslash escape is interpreted as it is expected.






                          share|improve this answer
























                            up vote
                            2
                            down vote













                            From man echo:



                             -e enable interpretation of backslash escapes

                            -E disable interpretation of backslash escapes (default)

                            If -e is in effect, the following sequences are recognized:

                            \ backslash

                            a alert (BEL)

                            b backspace

                            c produce no further output

                            e escape

                            f form feed

                            n new line

                            r carriage return

                            t horizontal tab

                            v vertical tab

                            NNN byte with octal value NNN (1 to 3 digits)

                            xHH byte with hexadecimal value HH (1 to 2 digits)

                            NOTE: your shell may have its own version of echo, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.


                            Please note the NOTE :) For example in sh there is no option -e for echo:



                            $ sh -c "echo -e 'hello n world'"
                            -e hello
                            world


                            You can see -e is output as regular text but the backslash escape is interpreted as it is expected.






                            share|improve this answer






















                              up vote
                              2
                              down vote










                              up vote
                              2
                              down vote









                              From man echo:



                               -e enable interpretation of backslash escapes

                              -E disable interpretation of backslash escapes (default)

                              If -e is in effect, the following sequences are recognized:

                              \ backslash

                              a alert (BEL)

                              b backspace

                              c produce no further output

                              e escape

                              f form feed

                              n new line

                              r carriage return

                              t horizontal tab

                              v vertical tab

                              NNN byte with octal value NNN (1 to 3 digits)

                              xHH byte with hexadecimal value HH (1 to 2 digits)

                              NOTE: your shell may have its own version of echo, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.


                              Please note the NOTE :) For example in sh there is no option -e for echo:



                              $ sh -c "echo -e 'hello n world'"
                              -e hello
                              world


                              You can see -e is output as regular text but the backslash escape is interpreted as it is expected.






                              share|improve this answer












                              From man echo:



                               -e enable interpretation of backslash escapes

                              -E disable interpretation of backslash escapes (default)

                              If -e is in effect, the following sequences are recognized:

                              \ backslash

                              a alert (BEL)

                              b backspace

                              c produce no further output

                              e escape

                              f form feed

                              n new line

                              r carriage return

                              t horizontal tab

                              v vertical tab

                              NNN byte with octal value NNN (1 to 3 digits)

                              xHH byte with hexadecimal value HH (1 to 2 digits)

                              NOTE: your shell may have its own version of echo, which usually supersedes the version described here. Please refer to your shell's documentation for details about the options it supports.


                              Please note the NOTE :) For example in sh there is no option -e for echo:



                              $ sh -c "echo -e 'hello n world'"
                              -e hello
                              world


                              You can see -e is output as regular text but the backslash escape is interpreted as it is expected.







                              share|improve this answer












                              share|improve this answer



                              share|improve this answer










                              answered Mar 15 at 11:53









                              pa4080

                              12.3k52256




                              12.3k52256




















                                  up vote
                                  1
                                  down vote













                                  A straight-forward alternative is to use manifest line feeds in the quoted string,



                                  echo "hello
                                  world"


                                  If you want to see the alignment, press enter after the first quotation character



                                  echo "
                                  hello beautiful
                                  wonderful world"


                                  and remove that line feed to avoid a blank first line of the output.






                                  share|improve this answer
























                                    up vote
                                    1
                                    down vote













                                    A straight-forward alternative is to use manifest line feeds in the quoted string,



                                    echo "hello
                                    world"


                                    If you want to see the alignment, press enter after the first quotation character



                                    echo "
                                    hello beautiful
                                    wonderful world"


                                    and remove that line feed to avoid a blank first line of the output.






                                    share|improve this answer






















                                      up vote
                                      1
                                      down vote










                                      up vote
                                      1
                                      down vote









                                      A straight-forward alternative is to use manifest line feeds in the quoted string,



                                      echo "hello
                                      world"


                                      If you want to see the alignment, press enter after the first quotation character



                                      echo "
                                      hello beautiful
                                      wonderful world"


                                      and remove that line feed to avoid a blank first line of the output.






                                      share|improve this answer












                                      A straight-forward alternative is to use manifest line feeds in the quoted string,



                                      echo "hello
                                      world"


                                      If you want to see the alignment, press enter after the first quotation character



                                      echo "
                                      hello beautiful
                                      wonderful world"


                                      and remove that line feed to avoid a blank first line of the output.







                                      share|improve this answer












                                      share|improve this answer



                                      share|improve this answer










                                      answered Mar 15 at 12:59









                                      sudodus

                                      20.3k32668




                                      20.3k32668



























                                           

                                          draft saved


                                          draft discarded















































                                           


                                          draft saved


                                          draft discarded














                                          StackExchange.ready(
                                          function ()
                                          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2faskubuntu.com%2fquestions%2f1015151%2fsplit-echos-output-on-two-lines%23new-answer', 'question_page');

                                          );

                                          Post as a guest













































































                                          Popular posts from this blog

                                          How do so many people here on Academia.SE, and in general, afford lavish higher education programs?

                                          Trouble downloading packages list due to a “Hash sum mismatch” error

                                          How do I move numbers in filenames, in a batch renaming operation?