English 中文(简体)
为什么“文件的结束”(EOF)是这里文件的 defacto delimeter? [已关闭]
原标题:Why is "End of File" (EOF) the defacto delimeter for here documents? [closed]

“文件的结束”一语从何处产生用于此文档?

something <<EOF
something else 1
something else 2
...
EOF

我假设有些历史可以证明非直觉限制字符串是合理的, 读到>Wikipedias 文章 还不够:为什么“file”仍然随处可见程序, 而流和块更常用于构建此文档?

最佳回答

它来自 Unix 传统, 其中 < a href=" "http://en.wikipedia.org/wiki/Empless_is_a_file" rel= "nofollow" > everything is a file . 这里的文件并不表示磁盘文件, 也不一定意味着任何相关的元数据 - 它意味着某种离现在通常称为流的东西更近一点的东西。 文件最多是由文件描述器访问的东西。 换句话说, 您正在产卵的过程的 STDIN 是一个文件 , 也就是一个文件 < / em >, 而异端由异端医生的 EOF 标记 。

问题回答

因为 EOF 代表“ 文件结束” 的 EOF 传统上一直用作在程序读取文件显示文件结束时返回的标记或例外的名称。 这是一个非常老的用法 。

因此,在这里写入文档时,您需要用一个符号来标记文件的结尾(这应该是不可能意外发生的),“EOF”自然会想到,如果你再用该词来指文件的结尾标记。由于这些标记经常被使用,即使那些“em'aren t 曾经这样思考过EOF的人也能够发现,因为他们在学习如何使用此文档时看到它作为例子。因此,使用方式会传播。

这只是一个惯例。在空壳脚本中,你几乎可以使用任何东西,例如,

cat <<stackoverflow
something else 1
something else 2
...
stackoverflow

bash 中,与它所说的 EOF 相同。





相关问题
Can Django models use MySQL functions?

Is there a way to force Django models to pass a field to a MySQL function every time the model data is read or loaded? To clarify what I mean in SQL, I want the Django model to produce something like ...

An enterprise scheduler for python (like quartz)

I am looking for an enterprise tasks scheduler for python, like quartz is for Java. Requirements: Persistent: if the process restarts or the machine restarts, then all the jobs must stay there and ...

How to remove unique, then duplicate dictionaries in a list?

Given the following list that contains some duplicate and some unique dictionaries, what is the best method to remove unique dictionaries first, then reduce the duplicate dictionaries to single ...

What is suggested seed value to use with random.seed()?

Simple enough question: I m using python random module to generate random integers. I want to know what is the suggested value to use with the random.seed() function? Currently I am letting this ...

How can I make the PyDev editor selectively ignore errors?

I m using PyDev under Eclipse to write some Jython code. I ve got numerous instances where I need to do something like this: import com.work.project.component.client.Interface.ISubInterface as ...

How do I profile `paster serve` s startup time?

Python s paster serve app.ini is taking longer than I would like to be ready for the first request. I know how to profile requests with middleware, but how do I profile the initialization time? I ...

Pragmatically adding give-aways/freebies to an online store

Our business currently has an online store and recently we ve been offering free specials to our customers. Right now, we simply display the special and give the buyer a notice stating we will add the ...

Converting Dictionary to List? [duplicate]

I m trying to convert a Python dictionary into a Python list, in order to perform some calculations. #My dictionary dict = {} dict[ Capital ]="London" dict[ Food ]="Fish&Chips" dict[ 2012 ]="...

热门标签