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?


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'


cat <<<hello\ world
  • @ilkkachu Yeah, you're right, there's no word-splitting there at all. Nov 22 '18 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 Nov 22 '18 at 22:46

From the manual:


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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.