June 2017
Beginner
502 pages
11h 26m
English
A here document is a form of redirection that forces the shell to read the input from the subsequent block of characters up to a user-defined delimiter, and then it uses this bunch of characters as a standard input for a command or a file descriptor. As we can see in the next example, the argument for the cat command is not provided on the command line or asked to the user, but it is written into the script between the two DELIMITER words:
#!/bin/bashcat << DELIMITERThis is a stringfollowed by anotherdate $(date +%Y.%m.%d)until the DELIMITER
Now, let's run it:
zarrelli:~$ ./here-date.sh This is a stringfollowed by anotherdate 2017.02.21until the
The delimiter at the right of << can be whatever string you want as long ...
Read now
Unlock full access