Chinaunix

标题: "here document"/"here string" 原理 [打印本页]

作者: yjh777    时间: 2016-01-27 10:38
标题: "here document"/"here string" 原理
  1. $ ls -l /proc/self/fd <<END
  2. kkk
  3. END
  4. 总用量 0
  5. lr-x------ 1 yjh fs-qe 64 1月  27 10:37 0 -> /tmp/sh-thd-216099019213 (deleted)
  6. lrwx------ 1 yjh fs-qe 64 1月  27 10:37 1 -> /dev/pts/29
  7. lrwx------ 1 yjh fs-qe 64 1月  27 10:37 2 -> /dev/pts/29
  8. lr-x------ 1 yjh fs-qe 64 1月  27 10:37 3 -> /proc/3296/fd
复制代码
  1. $ ls -l /proc/self/fd <<<"kkk"
  2. 总用量 0
  3. lr-x------ 1 yjh fs-qe 64 1月  27 10:38 0 -> /tmp/sh-thd-216098997507 (deleted)
  4. lrwx------ 1 yjh fs-qe 64 1月  27 10:38 1 -> /dev/pts/29
  5. lrwx------ 1 yjh fs-qe 64 1月  27 10:38 2 -> /dev/pts/29
  6. lr-x------ 1 yjh fs-qe 64 1月  27 10:38 3 -> /proc/3322/fd
复制代码
over
作者: ydzcjj    时间: 2016-01-27 11:03
学习了
刚开始接触用输出的比较多  输入的比较少  用cat来说明可能会更清楚一点
我想问第二个不是<<么 怎么有3个的?
作者: yjh777    时间: 2016-01-27 15:27
ydzcjj 发表于 2016-01-27 11:03
学习了
刚开始接触用输出的比较多  输入的比较少  用cat来说明可能会更清楚一点
我想问第二个不是


三个是here string,两个是here document

用ls是查看重定向后 fd/0 到底从哪儿来,这里两种here *方法,都是用临时文件实现的

作者: ydzcjj    时间: 2016-01-27 15:34
回复 3# yjh777


    谢谢解释,学习了!




欢迎光临 Chinaunix (http://bbs.chinaunix.net/) Powered by Discuz! X3.2