问题标签 [process-substitution]

For questions regarding programming in ECMAScript (JavaScript/JS) and its various dialects/implementations (excluding ActionScript). Note JavaScript is NOT the same as Java! Please include all relevant tags on your question; e.g., [node.js], [jquery], [json], [reactjs], [angular], [ember.js], [vue.js], [typescript], [svelte], etc.

0 投票
0 回答
182 浏览

bash - 上限日志文件大小

假设我正在写入日志文件:

有没有我可以使用的程序将日志文件限制在一定大小,也许像 5mb?

所以这可能看起来像:

使用流程替换或其他方式。这意味着如果它开始变得太大,它将删除文件开头的行。

0 投票
1 回答
279 浏览

bash - Force shell script to keep command in foreground after process substitution

I have a script that needs to run a jar and redirect its output to another executable, and I need to run this with a few different parameters. I need to run it each time in isolation because it's running some tests on execution time and I don't want them to be influenced by other stuff running. My problem is that once the first command has finished producing its output, the second command should keep on going (for quite a long time), but control returns to the shell and that command continues in background.

The script does something like:

but as soon as the java command in the first line has completed it goes straight to the next line, resulting in the path/to/other/script being executed twice at the same time.

To be more clear, I want the prompt to appear only after the whole first command line has finished, that is after path/to/other/script has finished its job.

How do I do that?

0 投票
2 回答
108 浏览

bash - 如何在 BASH 中使用进程替换字符串?

我知道我可以做类似的事情

但我想建立一串<(). 所以:

无需使用eval.

0 投票
3 回答
575 浏览

bash - Bash Process Substitution 使用 tee 和 while 循环

我想在 while 循环中使用 tee 的嵌套过程替代。

因此,我需要:

  • sample.file 中所有包含 "LINETOPROCESS" 表达式的行都应该被传递到循环中,并且它们将以 "--" 前缀打印。
  • 所有包含“SPECLINE”的行都需要在 tee 的第一个进程替换中打印(在 grep 中)。

我想避免多次对 sample.file 进行 cat-ting,因为它太大太重。

使用一个简单的 sample.test 文件:

我的结果:

我想要的结果:

或者我也可以接受这个作为输出:

更新1

greps 仅用于演示。我真的需要这两个替换。

  • sample.file 是一个 http 文件。
  • grep "SPECLINE" 将是 "hxselect -i -s ';' -c 'div.hour'
  • grep "LINESTOPROCESS" 将是 "hxselect -i -s ';' -c 'div.otherclass' | hxpipe

hx 程序不是面向行的。他们正在从标准输入读取并输出到标准输出。

因此,tee 的第一个命令将选择 'hour' 类的 div,并用 ';' 分隔它们。之后, tee 之后的管道将选择所有具有“otherclass”类的 div,hxpipe 会将其展平以便循环进行进一步处理。

0 投票
1 回答
58 浏览

linux - 使用 tee 将输入管道输入到两个进程替换

是否可以将输入通过管道传输到两个进程替换?可以用tee做吗?还没有找到解决办法。

我有一个命令,我想使用这样的进程替换来运行:

我试图通过管道将输入传递给 command2 和 command3,但我发现你不能从管道中读取两次。

如果可能的话,使用 tee 执行此操作的正确语法是什么?

0 投票
1 回答
259 浏览

linux - 使用重定向运算符的 Bash 命令“读取”行为

如果我执行以下命令:

和:

结果是:54

(带空格)有什么< <作用?

为什么_在“echo”命令中给出结果中的第一个单词?

上面的命令只是示例。

非常感谢

0 投票
1 回答
307 浏览

linux - 在 zsh 中混合进程替换和管道

使用 ZSH,我试图将 sed 命令包装到一个函数中,然后使用它,同时将管道与进程替代混合。让我用一个例子来解释:

如您所见,在这 3 种用法中的 2 种中有效。最后一个是这里让我感兴趣的一个。(请注意,所有命令都适用于 bash)

你能解释为什么在输入中使用进程替换的函数的输出不能通过管道使用吗?

我不是在寻找一种解决方法来使我的示例正常工作。我正在寻找解释,因为我找不到。

仅供参考sed,这里不相关,我尝试了多个其他命令(echo,cat ...),并得到了相同的结果

0 投票
1 回答
40 浏览

bash - 使用进程替换时无法加载此类文件

尝试使用erb加载库和渲染配置:

我想有条件地更新.env.rb,所以我认为我可以使用sed和使用进程替换来实现这一点,例如:

但这样做给了我:in 'require': cannot load such file -- /dev/fd/11 (LoadError)

我究竟做错了什么?

0 投票
1 回答
101 浏览

python - 为什么`script.py <(cat *.gz)`在python 2中与subprocess.Popen一起工作,但在python 3中却不行?

我们最近发现,如果我们通过进程替换为其输入文件提供了输入文件,我们在 python 3.x(但不是 python 2.x)中开发的脚本会阻塞,例如:

我们已经使用 gzip 以外的命令(例如 cat)进行了测试,只是为了看看我们是否会收到类似的错误。他们都抱怨/dev/fd/63(或/dev/fd/63.gz)不存在。这是(简化的)相关代码:

顺便说一句,我们进行分叉只是因为命令行 gzip 比使用 gzip.open 快得多,而且我们的脚本是一个长时间运行的工作程序 - 差异是几个小时。

我们正在解决这个问题,但想了解为什么它在 python 3 中不起作用但在 python 2 中起作用。

0 投票
1 回答
104 浏览

bash - 如何定义一个可以在多个 npm 脚本中自动使用的环境变量?

考虑以下 npm 脚本。

我想按如下方式使用它:

这将正确创建 Elm 应用程序的调试版本。然而,事实并非如此。不使用单引号,而是npm run使用双引号:

因此,输出不是我所期望的。在不编写自定义 shell 脚本的情况下解决此问题的最佳方法是什么?我想OUTPUT在两个不同的命令中使用该变量。但是,我只想在一个地方定义它。