[英]Treating output from one bash script as a file in another bash script
There are a few questions on this site phrased similarly, but none quite get at what I need.这个网站上有几个问题的措辞类似,但没有一个能完全满足我的需要。
I have a script that processes data from some file, in a manner something like...我有一个脚本可以处理来自某个文件的数据,其方式类似于...
infile=$1
grep foo $infile
#process line(s) containing "foo"
grep bar $infile
#process line(s) containing "bar"
grep yyy $infile
grep zzz $infile
#process together lines containing yyy and zzz
My question is, I would like for infile to be replaced with the output from another script.我的问题是,我希望将 infile 替换为另一个脚本中的 output。 I would rather not store the output in a temporary file.
我宁愿不将 output 存储在临时文件中。 How do I do this?
我该怎么做呢? Is there a way?
有办法吗? I thought about a named pipe but when I do that the script hangs after the first grep command (which, at least, is successful).
我想到了一个名为 pipe 的名字,但是当我这样做时,脚本在第一个 grep 命令(至少是成功的)之后挂起。 I haven't been able to find any other way.
我一直没能找到任何其他方式。
The command to do that is awk
:这样做的命令是
awk
:
infile=$1
awk '
/foo/ { #process line(s) containing "foo"}
/bar/ { #process line(s) containing "bar"}
/yyy/ && /zzz/ { #process together lines containing yyy and zzz}
' $infile
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.