一个 bash 管道中可以连接多少个命令?
我必须解析包含许多正则表达式的文件。我想通过串联 sed 'replace' 命令来做到这一点。所以问题是我最多可以在 bash 管道中连接多少个 sed 命令?
I have to parse a file with many regular expressions. I would like to do that with a concatenation of sed 'replace' commands. So the question is how many sed commands, at maximum, i can concatenate in a bash pipe?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
你问这个问题就说明你做错了什么。
首先,如果您想使用大量正则表达式,正如 John 指出的那样,您可以编写一个 sed 脚本。但为什么需要这么多正则表达式呢?正则表达式并不是所有解析任务的最佳匹配,编写实际的解析器或使用解析器生成器可能是解决问题的更好方法。
The fact that you're asking this question shows that you're doing something wrong.
First, if you want to use a lot of regular expressions, as John has pointed, you can write a sed script. But why do you need so many regular expressions? Regexps are not the best match for all parsing tasks, writing an actual parser or using a parser generator could be far better solutions to your problem.
据我所知,管道的数量没有限制,因为命令只是一个接一个地执行。唯一的限制是通过管道传入的数据量,或“管道缓冲区限制”。
有关更多详细信息,请参阅此处: https://unix.stackexchange.com/questions/ 11946/管道缓冲区有多大
As far as I know, there is no limit on the number of pipes, as the commands are simply executed one after the other. The only limit would be the quantity of data passed in through the pipe, or the "Pipe Buffer Limit."
See here for more details: https://unix.stackexchange.com/questions/11946/how-big-is-the-pipe-buffer