Here Documents

No, this is not an example of what you do when you have a dog named documents and you want him to come to you. I have found that the concept of the here document has caused much weeping and gnashing of teeth among script writers. More specifically, this capability has caused heads to be scratched when trying to make changes or additions to production- or admin-level scripts.

I think the reason for all the uproar is that the syntax is not intuitive and the name “here document” doesn't bring a picture to mind. Let's review. The > symbol redirects output, and the >> symbol redirects output but appends to the target file rather than clobbering the target. The < symbol redirects input so that it comes from the file appearing after the ...

Get Korn Shell Programming by Example now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.