{"id":227811,"date":"2025-01-25T12:58:12","date_gmt":"2025-01-25T11:58:12","guid":{"rendered":"https:\/\/glosarix.com\/glossary\/here-document-en\/"},"modified":"2025-01-25T12:58:12","modified_gmt":"2025-01-25T11:58:12","slug":"here-document-en","status":"publish","type":"glossary","link":"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/","title":{"rendered":"Here Document"},"content":{"rendered":"<p>Description: A &#8216;Here Document&#8217; is a type of redirection in shell scripting that allows multiple lines of input to be passed to a command. This mechanism is particularly useful for providing blocks of text in a more readable and structured manner, rather than using multiple echo commands or file redirections. The basic syntax of a &#8216;Here Document&#8217; involves the use of a delimiter that indicates the start and end of the text to be passed. This allows for including text that can span multiple lines, making it easier to create more complex and organized scripts. Additionally, &#8216;Here Documents&#8217; can include variables and commands, making them a powerful tool for dynamic content generation. Their use is common in shell scripts and scripting languages for creating configuration files, generating emails, or executing commands that require multiple lines of input. In summary, &#8216;Here Documents&#8217; are an essential feature in the toolkit of any developer working with scripting in various environments, providing an efficient and clear way to handle text input in their scripts.<\/p>\n<p>History: The concept of &#8216;Here Document&#8217; originated in the early days of Unix in the 1970s as part of the evolution of scripting languages. While there is no specific year marking its invention, its use has been documented in Unix shells since their early versions. As scripting languages evolved, &#8216;Here Document&#8217; became a standard feature in many shells, including Bourne Shell, Bash, and others. Its popularity has grown due to its ability to simplify text input in scripts, leading to its adoption in a variety of applications and programming environments.<\/p>\n<p>Uses: Here Documents are primarily used in shell scripting and other scripting languages to facilitate multi-line text input. They are especially useful for creating configuration files, generating emails, and executing commands that require extensive text blocks. They are also used for creating scripts that need to include dynamic content, such as the output of other commands or variable interpolation. Overall, their use enhances the readability and organization of code in complex scripts.<\/p>\n<p>Examples: An example of using a &#8216;Here Document&#8217; in a Bash script would be as follows:<\/p>\n<p>&#8220;`bash<br \/>\ncat << EOF\nThis is an example of a Here Document.\nIt can include multiple lines of text.\nEOF\n```\nThis script uses the 'cat' command to display the text between the 'EOF' delimiters. Another example would be creating a configuration file:\n\n```bash\ncat << CONFIG > file.conf<br \/>\n[section]<br \/>\nkey=value<br \/>\nCONFIG<br \/>\n&#8220;`<br \/>\nThis command creates a file named &#8216;file.conf&#8217; with the specified content.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Description: A &#8216;Here Document&#8217; is a type of redirection in shell scripting that allows multiple lines of input to be passed to a command. This mechanism is particularly useful for providing blocks of text in a more readable and structured manner, rather than using multiple echo commands or file redirections. The basic syntax of a [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"menu_order":0,"comment_status":"open","ping_status":"open","template":"","meta":{"footnotes":""},"glossary-categories":[11460],"glossary-tags":[12416],"glossary-languages":[],"class_list":["post-227811","glossary","type-glossary","status-publish","hentry","glossary-categories-shell-scripting-en","glossary-tags-shell-scripting-en"],"post_title":"Here Document ","post_content":"Description: A 'Here Document' is a type of redirection in shell scripting that allows multiple lines of input to be passed to a command. This mechanism is particularly useful for providing blocks of text in a more readable and structured manner, rather than using multiple echo commands or file redirections. The basic syntax of a 'Here Document' involves the use of a delimiter that indicates the start and end of the text to be passed. This allows for including text that can span multiple lines, making it easier to create more complex and organized scripts. Additionally, 'Here Documents' can include variables and commands, making them a powerful tool for dynamic content generation. Their use is common in shell scripts and scripting languages for creating configuration files, generating emails, or executing commands that require multiple lines of input. In summary, 'Here Documents' are an essential feature in the toolkit of any developer working with scripting in various environments, providing an efficient and clear way to handle text input in their scripts.\n\nHistory: The concept of 'Here Document' originated in the early days of Unix in the 1970s as part of the evolution of scripting languages. While there is no specific year marking its invention, its use has been documented in Unix shells since their early versions. As scripting languages evolved, 'Here Document' became a standard feature in many shells, including Bourne Shell, Bash, and others. Its popularity has grown due to its ability to simplify text input in scripts, leading to its adoption in a variety of applications and programming environments.\n\nUses: Here Documents are primarily used in shell scripting and other scripting languages to facilitate multi-line text input. They are especially useful for creating configuration files, generating emails, and executing commands that require extensive text blocks. They are also used for creating scripts that need to include dynamic content, such as the output of other commands or variable interpolation. Overall, their use enhances the readability and organization of code in complex scripts.\n\nExamples: An example of using a 'Here Document' in a Bash script would be as follows:\n\n```bash\ncat << EOF\nThis is an example of a Here Document.\nIt can include multiple lines of text.\nEOF\n```\nThis script uses the 'cat' command to display the text between the 'EOF' delimiters. Another example would be creating a configuration file:\n\n```bash\ncat << CONFIG > file.conf\n[section]\nkey=value\nCONFIG\n```\nThis command creates a file named 'file.conf' with the specified content.","yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v25.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Here Document - Glosarix<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Here Document - Glosarix\" \/>\n<meta property=\"og:description\" content=\"Description: A &#8216;Here Document&#8217; is a type of redirection in shell scripting that allows multiple lines of input to be passed to a command. This mechanism is particularly useful for providing blocks of text in a more readable and structured manner, rather than using multiple echo commands or file redirections. The basic syntax of a [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/\" \/>\n<meta property=\"og:site_name\" content=\"Glosarix\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:site\" content=\"@GlosarixOficial\" \/>\n<meta name=\"twitter:label1\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data1\" content=\"2 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/\",\"url\":\"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/\",\"name\":\"Here Document - Glosarix\",\"isPartOf\":{\"@id\":\"https:\/\/glosarix.com\/en\/#website\"},\"datePublished\":\"2025-01-25T11:58:12+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Portada\",\"item\":\"https:\/\/glosarix.com\/en\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Here Document\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/glosarix.com\/en\/#website\",\"url\":\"https:\/\/glosarix.com\/en\/\",\"name\":\"Glosarix\",\"description\":\"T\u00e9rminos tecnol\u00f3gicos - Glosarix\",\"publisher\":{\"@id\":\"https:\/\/glosarix.com\/en\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/glosarix.com\/en\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/glosarix.com\/en\/#organization\",\"name\":\"Glosarix\",\"url\":\"https:\/\/glosarix.com\/en\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/glosarix.com\/en\/#\/schema\/logo\/image\/\",\"url\":\"https:\/\/glosarix.com\/wp-content\/uploads\/2025\/04\/Glosarix-logo-192x192-1.png.webp\",\"contentUrl\":\"https:\/\/glosarix.com\/wp-content\/uploads\/2025\/04\/Glosarix-logo-192x192-1.png.webp\",\"width\":192,\"height\":192,\"caption\":\"Glosarix\"},\"image\":{\"@id\":\"https:\/\/glosarix.com\/en\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/GlosarixOficial\",\"https:\/\/www.instagram.com\/glosarixoficial\/\"]}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Here Document - Glosarix","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/","og_locale":"en_US","og_type":"article","og_title":"Here Document - Glosarix","og_description":"Description: A &#8216;Here Document&#8217; is a type of redirection in shell scripting that allows multiple lines of input to be passed to a command. This mechanism is particularly useful for providing blocks of text in a more readable and structured manner, rather than using multiple echo commands or file redirections. The basic syntax of a [&hellip;]","og_url":"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/","og_site_name":"Glosarix","twitter_card":"summary_large_image","twitter_site":"@GlosarixOficial","twitter_misc":{"Est. reading time":"2 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/","url":"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/","name":"Here Document - Glosarix","isPartOf":{"@id":"https:\/\/glosarix.com\/en\/#website"},"datePublished":"2025-01-25T11:58:12+00:00","breadcrumb":{"@id":"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/glosarix.com\/en\/glossary\/here-document-en\/"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/glosarix.com\/en\/glossary\/here-document-en\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Portada","item":"https:\/\/glosarix.com\/en\/"},{"@type":"ListItem","position":2,"name":"Here Document"}]},{"@type":"WebSite","@id":"https:\/\/glosarix.com\/en\/#website","url":"https:\/\/glosarix.com\/en\/","name":"Glosarix","description":"T\u00e9rminos tecnol\u00f3gicos - Glosarix","publisher":{"@id":"https:\/\/glosarix.com\/en\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/glosarix.com\/en\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/glosarix.com\/en\/#organization","name":"Glosarix","url":"https:\/\/glosarix.com\/en\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/glosarix.com\/en\/#\/schema\/logo\/image\/","url":"https:\/\/glosarix.com\/wp-content\/uploads\/2025\/04\/Glosarix-logo-192x192-1.png.webp","contentUrl":"https:\/\/glosarix.com\/wp-content\/uploads\/2025\/04\/Glosarix-logo-192x192-1.png.webp","width":192,"height":192,"caption":"Glosarix"},"image":{"@id":"https:\/\/glosarix.com\/en\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/GlosarixOficial","https:\/\/www.instagram.com\/glosarixoficial\/"]}]}},"_links":{"self":[{"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/glossary\/227811","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/glossary"}],"about":[{"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/types\/glossary"}],"author":[{"embeddable":true,"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/comments?post=227811"}],"version-history":[{"count":0,"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/glossary\/227811\/revisions"}],"wp:attachment":[{"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/media?parent=227811"}],"wp:term":[{"taxonomy":"glossary-categories","embeddable":true,"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/glossary-categories?post=227811"},{"taxonomy":"glossary-tags","embeddable":true,"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/glossary-tags?post=227811"},{"taxonomy":"glossary-languages","embeddable":true,"href":"https:\/\/glosarix.com\/en\/wp-json\/wp\/v2\/glossary-languages?post=227811"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}