How does “cat << EOF” work in bash?

前端 未结 9 1307
深忆病人
深忆病人 2020-11-22 12:24

I needed to write a script to enter multi-line input to a program (psql).

After a bit of googling, I found the following syntax works:

c         


        
9条回答
  •  故里飘歌
    2020-11-22 13:01

    This isn't necessarily an answer to the original question, but a sharing of some results from my own testing. This:

    < print.sh
    #!/bin/bash
    echo \$PWD
    echo $PWD
    test
    

    will produce the same file as:

    cat < print.sh
    #!/bin/bash
    echo \$PWD
    echo $PWD
    test
    

    So, I don't see the point of using the cat command.

提交回复
热议问题