Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Why is the command md5sum <<< 'ddd' (output: d6d88f2e50080b9602da53dac1102762 -) right, and md5sum << 'ddd' not?

What does <<< mean?

share|improve this question

The <<< starts a “here string”: The string is expanded and fed to the program’s stdin. (In your case, there is not much of expansion happening.) It is equivalent to this:

echo ddd | md5sum

On the other hand, << starts a here document. All the following lines up to one containing the marker ddd will comprise the input of the program. (You should use a marker that is not likely to appear in your data.) You could achieve the same effect as above like this:

md5sum <<END

There is one difference between <<END and <<'END': Without the quotes, any variables, escape sequences etc. in the here document will be expanded as usual.

share|improve this answer
Where it's not equivalent is that except in rc, <<< (like <<) uses a temporary file so can be used by commands that lseek their stdin. – Stéphane Chazelas May 19 '13 at 22:05

<<< introduces a here string: the string after <<< is passed as input to the command. This originates from rc (a Plan 9 shell), and is also present in zsh, ksh93 and bash.

<< introduces a here document: subsequent lines of the shell script are passed as input to the command, and the string after << is a terminator. Here documents work in all Bourne-style shells (Bourne, POSIX, ash, bash, ksh, zsh, …), C-style shells (csh, tcsh), and Plan 9 shells (rc, es).

share|improve this answer
No, <<< is not a ksh extension, the path is rc -> zsh -> ksh93 -> bash (ksh release notes acknowledge for once borrowing the feature from zsh). << also works in rc style shells – Stéphane Chazelas May 19 '13 at 21:52
There's a difference between the rc and zsh <<< though in that rc's doesn't include a trailing newline character and doesn't use a temp file (uses a pipe and an extra process feeding it at least in the port to Linux). – Stéphane Chazelas May 19 '13 at 22:02
To be more precise it looks like <<< comes from the Unix port of rc as it doesn't look like the Plan9 rc has it. – Stéphane Chazelas May 19 '13 at 22:21
+ nice link :)..... – Grijesh Chauhan May 20 '13 at 5:48

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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