什么是这里有文件吗?(a here document?)

在计算机和计算机编程方面,here文档是一个文本列表,用于定义通过使用特殊运算符传递到程序的输入,因此可以更容易地传递异常长的命令块或文本。“Here document”或“herdoc”更像是一个通用术语,因为Here文档如何操作以及它可以包含的内容的确切实现将因操作系统、应用程序或编程语言的不同而有所不同。不管名称意味着什么,here文档通常不是一个单独的文件,而是脚本中的一块文本,或者直接在...

在计算机和计算机编程方面,here文档是一个文本列表,用于定义通过使用特殊运算符传递到程序的输入,因此可以更容易地传递异常长的命令块或文本。“Here document”或“herdoc”更像是一个通用术语,因为Here文档如何操作以及它可以包含的内容的确切实现将因操作系统、应用程序或编程语言的不同而有所不同。不管名称意味着什么,here文档通常不是一个单独的文件,而是脚本中的一块文本,或者直接在程序命令末尾键入或插入。here文档的主要用途是通过命令行中的脚本或批处理文件执行程序,其中heredoc提供要执行的程序的指令列表或要处理的程序的输入。根据许多因素,here文档可以是一个简单的单词列表,也可以包含操作系统或目标应用程序可以破译的复杂变量或编程代码。

The "enter" key performs the same function as a carriage return, which may be included in a here document.

在最基本的术语中,here文档只是包含制表符、回车符和换行符等格式字符的文本列表。将参数传递给从命令行执行的程序是一种方便的方法,尤其是在使用脚本或批处理文件等包装文件的情况下。herdoc中包含的文本被发送到正在执行的程序,就好像用户输入的文本与它显示的完全一样。这允许一个单独的heredoc被反复使用,以给程序提供相同的输入,这样它就可以重复执行相同的任务,而不需要用户手动重新输入所有内容。

通过发送电子邮件的简单命令行sendmail程序可以看到here文档如何工作的一个示例。执行时,sendmail程序首先要求用户输入目标电子邮件地址;然后,它会询问电子邮件的主题,最后是电子邮件的文本。如果从命令行执行,用户将通过键入信息、点击返回键并等待程序响应来响应每个提示。在包装文件中使用heredoc时,可以提前键入要提供给sendmail程序的所有信息,包括按下返回键,并将其保存在包装文件中。这样,当使用heredoc执行sendmail程序时,输入会自动反馈到程序,并发送电子邮件,而无需用户执行更多操作。

  • 发表于 2021-12-10 15:16
  • 阅读 ( 122 )
  • 分类:互联网

你可能感兴趣的文章

这里是macos存储照片、书籍、音乐和其他文件的地方

... ~/Library/Containers/com.apple.BKAgentService/Data/Documents/iBooks/Books If you have enabled iCloud sync for iBooks: ~/Library/Mobile Documents/iCloud~com~apple~iBooks/Documents/ ...

  • 发布于 2021-03-12 00:19
  • 阅读 ( 219 )

如何用代码读写xml文件

... DOM:Document对象模型包括用于处理XML工件(如元素、节点、属性等)的类。domapi将完整的XML文档加载到内存中进行处理,因此不太适合处理大型XML文件。 SAX:Simple-...

  • 发布于 2021-03-12 02:25
  • 阅读 ( 417 )

javascript压缩器:如何以及为什么缩小js

...l": "Mark VII" }];window.onload = function() { // setup the button click document.getElementById("theButton").onclick = function() { doWork() };}function doWork() { // ajax the JSON to the server $.post("receiver", cars, function(){ }); // stop link reloading the page event.preventDefault...

  • 发布于 2021-03-13 16:08
  • 阅读 ( 232 )

什么是javascript?它是如何工作的?

...的部分需要学习:web浏览器的工作原理和文档对象模型(documentobjectmodel,DOM)。 ...

  • 发布于 2021-03-18 04:01
  • 阅读 ( 282 )

如何在linux中轻松地加密和解密文件和目录

...Linux的魔力,这就没有问题了。例如,如果要加密名为“documents”的目录,可以使用以下命令: ...

  • 发布于 2021-03-26 14:56
  • 阅读 ( 189 )

为什么~代表macos和linux上的主文件夹?

...。 例如,有一个tilde,~,它代表您的主文件夹。键入cd~/Documents会切换到当前用户主目录中的Documents文件夹,这样我就不用每次都键入/Users/justinpot/Documents了。当然,这是一个方便的快捷方式,但是为什么要用这个特殊的字符呢...

  • 发布于 2021-04-07 04:26
  • 阅读 ( 157 )

选择多个文件时,如何使“打开方式”菜单可用?

...首先,IT解决方案: Add the registry key text shown below to a text document, save it as OpenWith.txt, then change it to OpenWith.reg. Next, double click on it to import the new registry setting. Make sure the registry key’s value points to chrome.exe along with the correct full path to its...

  • 发布于 2021-04-08 16:17
  • 阅读 ( 228 )

为什么扫描仪使用pdf作为默认文件格式?

...t of scanning software has PDF set as the default format for newly created documents. Why is this? As I understand it, scanned documents are pixel based pictures like those in cameras. I am unaware of any cameras that store pictures using the PDF format. What does the PDF format bring to the table s...

  • 发布于 2021-04-08 22:55
  • 阅读 ( 132 )

如何在Windows10中恢复“所有最近使用的文件”列表?

...icular app. For example, I can look at Microsoft Word’s icon and see the documents recently opened in it. I am unable to find a simple “these are the last ten documents/files opened with any application”, which is very useful if I have not pinned the apps in question to my taskbar. This featur...

  • 发布于 2021-04-09 00:41
  • 阅读 ( 249 )

软件能区分台式电脑和笔记本电脑吗?

...epending on the manufacturer). For Windows, refer to the following TechNet documentation to determine your computer chassis type: Identifying the Chassis Type of a Computer 然后是Technik帝国的答案: To add to the other answer here regarding Linux, Windows software can also access this infor...

  • 发布于 2021-04-09 23:35
  • 阅读 ( 202 )
nm1840xt2u7
nm1840xt2u7

0 篇文章

相关推荐