There is a command I don't understand:
custom_command << EOF!!
I want to ask what EOF!! is in the bash script. I did find EOF with google, but google will ignore the "!!" automatically, so I cannot find EOF!!.
I know the end of the file token, but I don't exactly know what it means with the "!!" in the script. Is this a mark to force something to do something like in vim's wq! ?
Plus, why and when should we use EOF!! instead of EOF?
The bash manual lists this under "Event designators", saying:
I simply searched for "bash manual double exclamation".
It's probably just a weird heredoc.
Example:
Note: this only works in script files. The command line parser interprets
!!
.You can use whatever string as here document terminator.
EOF!!
is just what the person writing the script decided to use.As others already wrote, this is a here-document.
The token used for that should be chosen carefully; as the probability that the here-document contains
EOF!!
is lower than forEOF
itself, they chose that.I suppose they checked it does not harm before using it;
!!
in a script does NOT refer to the history, but it stays as it is.On the command line,
!!
would be expanded to the last command executed. Bash will print the line for you:In a script, though, history expansion is disabled by default, so the exclamation marks are part of the word.
Produces:
To enable history and history expansion in a script, add the following lines: