bash 想在unix中的tail命令后退出

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/27010943/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 11:49:04  来源:igfitidea点击:

want to exit after tail command in unix

bashshellunixhadoop

提问by Mars

I am using shell scripts , which performs following command

我正在使用 shell 脚本,它执行以下命令

hadoop fs -cat /input-path/* | grep "text" | tail -1

I want to exit after this command, so that my shell scripts will execute another command.

我想在这个命令之后退出,这样我的 shell 脚本就会执行另一个命令。

回答by anubhava

You can use this sedinstead to exit as soon as textis found:

您可以使用它sed来在text找到后立即退出:

sed '/text/q' <(hadoop fs -cat /input-path/*)