In this post and one or two others I've seen things like:

osascript <<EOS
-- some AppleScript code

I expect it's part of bash and presumably other shells... or is it an AppleScript/osascript specific thing? I've Googled, man'd, searched, etc. in vain.

I can infer from context more or less what it's doing, but can anyone tell me what officially is this <<EOS ... EOS thing, and/or point me to documentation for it?


  • does this link help?- mywiki.wooledge.org/HereDocument
    – fd0
    Apr 27 at 11:29
  • Searching for << in man bash might help :-)
    – nohillside
    Apr 27 at 13:20
  • @fdo & @nohillside, ok, I was searching everywhere for EOS and <<EOS, with no luck because (I now realize) there's nothing special about the EOS. It can be (almost) anything. It's purely the << that's key. That wooledge link is very clear. Especially the "Here, somecommand can be any program that reads from standard input (cat is by far the most common), and WORD can be any delimiter word you like. (EOF is a common choice.)". Thanks!
    – DavidT
    Apr 28 at 0:47

2 Answers 2


It is a here document (heredoc), and is built-in to several shells such as bash and zsh. The text between the delimiting identifiers (EOS in this case) is redirected to the command.


(Thanks to @red_menace, @fdo, and @nohillside so far. I've upvoted @red_menace's. It's "correct", but I found it difficult to grasp. I didn't really get it, until I read @fdo's link (first comment) as well. So, I feel this needs a more comprehensive answer for anyone else looking...)

First, it has nothing to do with AppleScript. Instead, in my example in the question:

  • the osascript part can be "any program[/commmand] that can read from standard input (cat is by far the most common)."**
  • the -- some AppleScript Code part is any number of lines that you could otherwise type into standard input or feed into the "program" from a file, etc.
  • In the <<EOS part, The EOS isn't special. It's purely the << that's key. The EOS part can be pretty much any single word (ie. string, no spaces or most special characters, etc.)

The result: it will perform the command with the encapsulated text as its input.

In my example, osascript is simply a shell command that receives AppleScript code as its input and runs that code as if the same code was run in Script Editor, etc.

**Quoted from @fdo's link. See that for more details

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .