Here documents in bash explained
Introduction Input/output redirection is an extremely important aspect of writing bash shell scripts and working with the bash shell command line interface in general. A here document is a form of I/O redirection that tells the bash shell to read input from the current source until a line containing only the delimiter is seen. This delimiter is known as the limit string. The limit string is preceded by the symbol << followed by the input commands or lines that we wish to redirect. We type the limit string again once we are done writing the input statements/commands that are to be redirected to indicate the end of the here document. The effect of enclosing a set of commands is that is redirects the output of the command block into the stdin of the program or command to which the stdin is directed to. Given below is the syntax for creating and using a here document: Command <<MyUniqueLimitString some text some more text MyUniqueLimitString In the above statements, the string MyUniqueLimitString serves as the limit string for the here document. Note: There should not be any space between the << symbol and the limit string. If there are any characters between the limit string and the << symbol then the here document is unlikely to work. Also the limit string that terminates the here document should not have any space...
Read More