当我定向到文件时,awk冻结 [英] awk freezing when I direct to a file

查看:56
本文介绍了当我定向到文件时,awk冻结的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

因此,当我在Mac上运行此程序时:

So when I run this on a mac:

awk 'END { for (name in ENVIRON) {
  print "key: "name; }
}' >> app-deployment.yaml

awk冻结了.如果我将其更改为仅打印到/dev/null这样

awk just freezes. If I change it to just print to /dev/null like this

awk 'END { for (name in ENVIRON) {
  print "key: "name; }
}' < /dev/null

工作正常.我的重定向做错了吗?我在这还有别的地方吗?

It works fine. Am I doing something wrong with my redirection? Is there something else I'm doing wrong here?

推荐答案

END更改为BEGIN即可在没有任何输入的情况下工作:

Change END to BEGIN to be able to work without any input:

awk 'BEGIN { for (name in ENVIRON) {
  print "key: "name; }
}' >> app-deployment.yaml

这篇关于当我定向到文件时,awk冻结的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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