分页: 1 / 1

求助:here scripts

发表于 : 2011-05-08 9:48
nigo
http://linuxcommand.org/wss0030.php

A here script (also sometimes called a here document) is an additional form of I/O redirection. It provides a way to include content that will be given to the standard input of a command.

如何理解呢?不是太明白到底什么是here scripts,请教了

Re: 求助:here scripts

发表于 : 2011-05-08 10:44
lilydjwg

代码: 全选

cat <<HereDoc
This is the so-called heredoc writing in the script but as the input.
HereDoc

Re: 求助:here scripts

发表于 : 2011-05-08 10:52
xjack
就是标记之间的所有命令被定向到<<符号之前的那个command

代码: 全选

#!/bin/bash
lftp << someMessHere
open http://mirror.bjtu.edu.cn/gnu/gcc
get -c README.olderversions
someMessHere
又比如

代码: 全选

:<<anyThingHere
被暂时屏蔽的代码
anyThingHere

Re: 求助:here scripts

发表于 : 2011-05-08 22:28
fnan
简洁的说就是一种输入重定向。

Re: 求助:here scripts

发表于 : 2011-05-09 10:05
nigo
昨天有事情,不能上网,不好意思啊。
我还是不理解,什么是here scripts呢?
比如下面一个脚本:
#!/bin/bash
命令一 << 标记号
命令二
命令三
标记号

是命令一被称为here script,还是这个脚本被称为here script呢?还是??

Re: 求助:here scripts

发表于 : 2011-05-09 10:45
nigo
已解决:
命令二,命令三 执行后,它的执行结果,被当做 标准输入 传送给 命令一
本来命令一是需要一个文件当参数的,可是这里没有文件,而是命令二和命令三执行的结果,这个结果被当做一个文件了,但是不是一个文件,而只是一个字符串(标准输入),这个重定向被叫做here script。
:em06