什么是EOF!在bash脚本? [英] What is EOF!! in the bash script?

查看:187
本文介绍了什么是EOF!在bash脚本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有一个命令,我不明白:

There is a command I don't understand:

custom_command << EOF!!

我要问什么EOF!在bash脚本。我没有找到EOF谷歌,但谷歌将忽略!!自动,所以我不能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!!.

我知道文件标记的结束,但我不知道到底是什么在!!的意思在该脚本。这是一个标志,强制事做类似Vim的WQ! ?

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! ?

此外,为什么我们何时应该使用EOF!而不是EOF?

Plus, why and when should we use EOF!! instead of EOF?

推荐答案

在命令行中, !! 将扩大到最后执行的命令。庆典将打印行你:

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 <<EOF!!
cat <<EOFls
>

在脚本中,虽然历史扩展默认是禁用的,所以惊叹号是单词的一部分。

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

#! /bin/bash
ls
cat <<EOF!!
echo 1
EOFls
echo 2

产地:

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

这篇关于什么是EOF!在bash脚本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆