What is EOF!! in the bash script?

后端 未结 5 1625
萌比男神i
萌比男神i 2021-02-13 12:08

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 googl

5条回答
  •  余生分开走
    2021-02-13 13:12

    On the command line, !! would be expanded to the last command executed. Bash will print the line for you:

    $ ls
    a.txt  b.txt
    $ cat <
    

    In a script, though, history expansion is disabled by default, so the exclamation marks are part of the word.

    #! /bin/bash
    ls
    cat <

    Produces:

    a.txt  b.txt
    script.sh: line 7: warning: here-document at line 3 delimited by end-of-file (wanted `EOF!!')
    echo 1
    EOFls
    echo 2
    

    To enable history and history expansion in a script, add the following lines:

    set -o history
    set -H
    

提交回复
热议问题