免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 2010 | 回复: 7
打印 上一主题 下一主题

着急啊!求“here文档”手册! [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-06-22 12:43 |只看该作者 |倒序浏览
感觉自己对shell中的here文档了解已经查不多了,可是现在怎么写出here文档怎么老是不能运行呢!哪位达人有关于here文档的手册,给俺弄一份吧!小弟实在感激得都要掉泪了(哈哈,呵呵……………………………………)

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
2 [报告]
发表于 2006-06-22 12:52 |只看该作者

  1.    Here Documents
  2.        This type of redirection instructs the shell to read  input  from  the
  3.        current  source  until  a  line containing only word (with no trailing
  4.        blanks) is seen.  All of the lines read up to that point are then used
  5.        as the standard input for a command.

  6.        The format of here-documents is:

  7.               <<[-]word
  8.                       here-document
  9.               delimiter

  10.        No parameter expansion, command substitution, arithmetic expansion, or
  11.        pathname expansion is performed on word.  If any  characters  in  word
  12.        are  quoted, the delimiter is the result of quote removal on word, and
  13.        the lines in the here-document are not expanded.  If word is unquoted,
  14.        all  lines  of the here-document are subjected to parameter expansion,
  15.        command substitution, and arithmetic expansion.  In the  latter  case,
  16.        the  character  sequence  \<newline> is ignored, and \ must be used to
  17.        quote the characters \, $, and '.

  18.        If the redirection operator is <<-, then all  leading  tab  characters
  19.        are stripped from input lines and the line containing delimiter.  This
  20.        allows here-documents within shell scripts to be indented in a natural
  21.        fashion.
复制代码


不知道manpage算不算资料?

论坛徽章:
0
3 [报告]
发表于 2006-06-22 12:55 |只看该作者
谢谢版主!
这个看过了,有没有比这还详细一点的,最好有若干个例子的那种!呵呵…………

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
4 [报告]
发表于 2006-06-22 13:07 |只看该作者
为什么会有?

论坛徽章:
0
5 [报告]
发表于 2006-06-22 13:21 |只看该作者
为什么会没有?呵呵…………

麻烦版主看看下面的脚本有无问题?谢谢!!!

#!/bin/bash

cd /mnt << EOF
ls
EOF

论坛徽章:
8
摩羯座
日期:2014-11-26 18:59:452015亚冠之浦和红钻
日期:2015-06-23 19:10:532015亚冠之西悉尼流浪者
日期:2015-08-21 08:40:5815-16赛季CBA联赛之山东
日期:2016-01-31 18:25:0515-16赛季CBA联赛之四川
日期:2016-02-16 16:08:30程序设计版块每日发帖之星
日期:2016-06-29 06:20:002017金鸡报晓
日期:2017-01-10 15:19:5615-16赛季CBA联赛之佛山
日期:2017-02-27 20:41:19
6 [报告]
发表于 2006-06-22 13:26 |只看该作者
语法上没问题

不过请再看看manpage中的第一句
       This type of redirection instructs the shell to read  input  from  the
       current  source  until  a  line containing only word (with no trailing
       blanks) is seen.  All of the lines read up to that point are then used
       as the standard input for a command.

cd命令要 standard input干嘛?

论坛徽章:
0
7 [报告]
发表于 2006-06-22 14:59 |只看该作者
同意waker说的,cd要什么输入阿,顺序执行不就完了

论坛徽章:
0
8 [报告]
发表于 2006-06-22 15:39 |只看该作者
好像明白了,又好像没明白!!唉………………
版主能否再给大概讲一讲,多谢了!!!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP