What is the end of here string?

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











up vote
0
down vote

favorite












It seemed to me that the end of a here string is newline. I realize I am wrong:



$ cat <<< hello world
cat: world: No such file or directory


What can signify the end of a here string?










share|improve this question

























    up vote
    0
    down vote

    favorite












    It seemed to me that the end of a here string is newline. I realize I am wrong:



    $ cat <<< hello world
    cat: world: No such file or directory


    What can signify the end of a here string?










    share|improve this question























      up vote
      0
      down vote

      favorite









      up vote
      0
      down vote

      favorite











      It seemed to me that the end of a here string is newline. I realize I am wrong:



      $ cat <<< hello world
      cat: world: No such file or directory


      What can signify the end of a here string?










      share|improve this question













      It seemed to me that the end of a here string is newline. I realize I am wrong:



      $ cat <<< hello world
      cat: world: No such file or directory


      What can signify the end of a here string?







      bash io-redirection here-string






      share|improve this question













      share|improve this question











      share|improve this question




      share|improve this question










      asked Nov 22 at 21:28









      Ben

      2769




      2769




















          2 Answers
          2






          active

          oldest

          votes

















          up vote
          3
          down vote



          accepted










          The syntax of a here string is:




          <<< word



          where a word is a sequence of characters treated as a unit by the shell, delimited by whitespace. That could be a single regular word (hello), a single- or double-quoted string ('hello world', "hello world"), a parameter or command substitution ($foo, $(...)), something assembled with backslash escapes, or a combination of those joined together.



          You can have multiple here-documents or here-strings on a single line, so the end of the line can't work as the only delimiter, though it will end there if not already (unless the newline is backslash-escaped).



          You would get the effect you wanted with



          cat <<<'hello world'


          or



          cat <<<hello world





          share|improve this answer






















          • @ilkkachu Yeah, you're right, there's no word-splitting there at all.
            – Michael Homer
            Nov 22 at 21:59










          • <<< comes from zsh (and the Unix variant of rc), and $IFS was never involved there (nor in ksh93 nor mksh nor yash which also copied that operator) but in bash versions prior to 4.4, unquoted expansions in the word after <<< were subject to word splitting (and the resulting words joined with space) which is why you do need to write it as cat <<< "$var" if you want to support bash versions 4.3 or older. That was fixed in 4.4
            – Stéphane Chazelas
            Nov 22 at 22:46

















          up vote
          2
          down vote













          From the manual:




          [n]<<<word




          The end is one word, not multiple words. So in this example, the first word is hello and terminates the here string. The next word is world, it is just an ordinary argument to cat, and cat assumes it is a file name to read.



          You could write it more clearly this way:



          $ cat world <<< hello





          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%2f483545%2fwhat-is-the-end-of-here-string%23new-answer', 'question_page');

            );

            Post as a guest















            Required, but never shown

























            2 Answers
            2






            active

            oldest

            votes








            2 Answers
            2






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            3
            down vote



            accepted










            The syntax of a here string is:




            <<< word



            where a word is a sequence of characters treated as a unit by the shell, delimited by whitespace. That could be a single regular word (hello), a single- or double-quoted string ('hello world', "hello world"), a parameter or command substitution ($foo, $(...)), something assembled with backslash escapes, or a combination of those joined together.



            You can have multiple here-documents or here-strings on a single line, so the end of the line can't work as the only delimiter, though it will end there if not already (unless the newline is backslash-escaped).



            You would get the effect you wanted with



            cat <<<'hello world'


            or



            cat <<<hello world





            share|improve this answer






















            • @ilkkachu Yeah, you're right, there's no word-splitting there at all.
              – Michael Homer
              Nov 22 at 21:59










            • <<< comes from zsh (and the Unix variant of rc), and $IFS was never involved there (nor in ksh93 nor mksh nor yash which also copied that operator) but in bash versions prior to 4.4, unquoted expansions in the word after <<< were subject to word splitting (and the resulting words joined with space) which is why you do need to write it as cat <<< "$var" if you want to support bash versions 4.3 or older. That was fixed in 4.4
              – Stéphane Chazelas
              Nov 22 at 22:46














            up vote
            3
            down vote



            accepted










            The syntax of a here string is:




            <<< word



            where a word is a sequence of characters treated as a unit by the shell, delimited by whitespace. That could be a single regular word (hello), a single- or double-quoted string ('hello world', "hello world"), a parameter or command substitution ($foo, $(...)), something assembled with backslash escapes, or a combination of those joined together.



            You can have multiple here-documents or here-strings on a single line, so the end of the line can't work as the only delimiter, though it will end there if not already (unless the newline is backslash-escaped).



            You would get the effect you wanted with



            cat <<<'hello world'


            or



            cat <<<hello world





            share|improve this answer






















            • @ilkkachu Yeah, you're right, there's no word-splitting there at all.
              – Michael Homer
              Nov 22 at 21:59










            • <<< comes from zsh (and the Unix variant of rc), and $IFS was never involved there (nor in ksh93 nor mksh nor yash which also copied that operator) but in bash versions prior to 4.4, unquoted expansions in the word after <<< were subject to word splitting (and the resulting words joined with space) which is why you do need to write it as cat <<< "$var" if you want to support bash versions 4.3 or older. That was fixed in 4.4
              – Stéphane Chazelas
              Nov 22 at 22:46












            up vote
            3
            down vote



            accepted







            up vote
            3
            down vote



            accepted






            The syntax of a here string is:




            <<< word



            where a word is a sequence of characters treated as a unit by the shell, delimited by whitespace. That could be a single regular word (hello), a single- or double-quoted string ('hello world', "hello world"), a parameter or command substitution ($foo, $(...)), something assembled with backslash escapes, or a combination of those joined together.



            You can have multiple here-documents or here-strings on a single line, so the end of the line can't work as the only delimiter, though it will end there if not already (unless the newline is backslash-escaped).



            You would get the effect you wanted with



            cat <<<'hello world'


            or



            cat <<<hello world





            share|improve this answer














            The syntax of a here string is:




            <<< word



            where a word is a sequence of characters treated as a unit by the shell, delimited by whitespace. That could be a single regular word (hello), a single- or double-quoted string ('hello world', "hello world"), a parameter or command substitution ($foo, $(...)), something assembled with backslash escapes, or a combination of those joined together.



            You can have multiple here-documents or here-strings on a single line, so the end of the line can't work as the only delimiter, though it will end there if not already (unless the newline is backslash-escaped).



            You would get the effect you wanted with



            cat <<<'hello world'


            or



            cat <<<hello world






            share|improve this answer














            share|improve this answer



            share|improve this answer








            edited Nov 22 at 21:58

























            answered Nov 22 at 21:36









            Michael Homer

            44.8k7117156




            44.8k7117156











            • @ilkkachu Yeah, you're right, there's no word-splitting there at all.
              – Michael Homer
              Nov 22 at 21:59










            • <<< comes from zsh (and the Unix variant of rc), and $IFS was never involved there (nor in ksh93 nor mksh nor yash which also copied that operator) but in bash versions prior to 4.4, unquoted expansions in the word after <<< were subject to word splitting (and the resulting words joined with space) which is why you do need to write it as cat <<< "$var" if you want to support bash versions 4.3 or older. That was fixed in 4.4
              – Stéphane Chazelas
              Nov 22 at 22:46
















            • @ilkkachu Yeah, you're right, there's no word-splitting there at all.
              – Michael Homer
              Nov 22 at 21:59










            • <<< comes from zsh (and the Unix variant of rc), and $IFS was never involved there (nor in ksh93 nor mksh nor yash which also copied that operator) but in bash versions prior to 4.4, unquoted expansions in the word after <<< were subject to word splitting (and the resulting words joined with space) which is why you do need to write it as cat <<< "$var" if you want to support bash versions 4.3 or older. That was fixed in 4.4
              – Stéphane Chazelas
              Nov 22 at 22:46















            @ilkkachu Yeah, you're right, there's no word-splitting there at all.
            – Michael Homer
            Nov 22 at 21:59




            @ilkkachu Yeah, you're right, there's no word-splitting there at all.
            – Michael Homer
            Nov 22 at 21:59












            <<< comes from zsh (and the Unix variant of rc), and $IFS was never involved there (nor in ksh93 nor mksh nor yash which also copied that operator) but in bash versions prior to 4.4, unquoted expansions in the word after <<< were subject to word splitting (and the resulting words joined with space) which is why you do need to write it as cat <<< "$var" if you want to support bash versions 4.3 or older. That was fixed in 4.4
            – Stéphane Chazelas
            Nov 22 at 22:46




            <<< comes from zsh (and the Unix variant of rc), and $IFS was never involved there (nor in ksh93 nor mksh nor yash which also copied that operator) but in bash versions prior to 4.4, unquoted expansions in the word after <<< were subject to word splitting (and the resulting words joined with space) which is why you do need to write it as cat <<< "$var" if you want to support bash versions 4.3 or older. That was fixed in 4.4
            – Stéphane Chazelas
            Nov 22 at 22:46












            up vote
            2
            down vote













            From the manual:




            [n]<<<word




            The end is one word, not multiple words. So in this example, the first word is hello and terminates the here string. The next word is world, it is just an ordinary argument to cat, and cat assumes it is a file name to read.



            You could write it more clearly this way:



            $ cat world <<< hello





            share|improve this answer
























              up vote
              2
              down vote













              From the manual:




              [n]<<<word




              The end is one word, not multiple words. So in this example, the first word is hello and terminates the here string. The next word is world, it is just an ordinary argument to cat, and cat assumes it is a file name to read.



              You could write it more clearly this way:



              $ cat world <<< hello





              share|improve this answer






















                up vote
                2
                down vote










                up vote
                2
                down vote









                From the manual:




                [n]<<<word




                The end is one word, not multiple words. So in this example, the first word is hello and terminates the here string. The next word is world, it is just an ordinary argument to cat, and cat assumes it is a file name to read.



                You could write it more clearly this way:



                $ cat world <<< hello





                share|improve this answer












                From the manual:




                [n]<<<word




                The end is one word, not multiple words. So in this example, the first word is hello and terminates the here string. The next word is world, it is just an ordinary argument to cat, and cat assumes it is a file name to read.



                You could write it more clearly this way:



                $ cat world <<< hello






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Nov 22 at 21:34









                RalfFriedl

                5,0873925




                5,0873925



























                    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%2f483545%2fwhat-is-the-end-of-here-string%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?

                    Bahrain

                    Postfix configuration issue with fips on centos 7; mailgun relay