如何使用一个循环这里文件? [英] How to use a here document in a loop?

查看:87
本文介绍了如何使用一个循环这里文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

本作品:

name="test.txt"

yap -q << % > $name
  [experiment_yap],
  exp1_min(brother,2).
%

这不:

for i in 01 02 03 04 05
do
  name="test.txt"

  yap -q << % > $name
    [experiment_yap],
    exp1_min(brother,2).
  %
done

我收到第19行:语法错误:意外的文件结尾

I receive line 19: syntax error: unexpected end of file

推荐答案

这不是在一个循环,这里有显著之中。 庆典并不真正知道或关心压痕 - 承认定界符结​​束时终止字符串的必须的是在该行的开头,这使得你的循环如下:

It's not being in a loop that's significant here. bash doesn't really know or care about indentation -- to recognize the end of the heredoc the terminating string must be at the beginning of the line, which makes your loop look like:

for i in 01 02 03 04 05
do
  name="test.txt"

  yap -q << % > $name
    [experiment_yap],
    exp1_min(brother,2).
%
done

这篇关于如何使用一个循环这里文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆