同时管道grep和重定向到标准输出 [英] Simultaneous pipe to grep and redirect to stdout

查看:117
本文介绍了同时管道grep和重定向到标准输出的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在Linux bash中,我试图运行一个命令和grep作为参数:

 命令| grep 

但是,我需要将 commad 的结果重定向到stdout并同时将其管理为grep(我需要在stdout中看到 grep 结果和命令结果)。

我搜索了一下,尝试了一些变化,例如:

 命令| tee / dev / tty | grep 

但是,没有运气。

我不想用像...... / $>

 命令
命令| grep

因为它很丑:)

感谢,

解决方案

尝试

  command |请注意,这两个符号之间没有空格:<$ c $> $($ grep)

c>>(。


In Linux bash, I am trying to run a command and grep for an argument:

command | grep

However, I need to redirect the result of the commad to the stdout and simultaneously pipe it to grep (I need to see both the grep result and the command result in stdout).

I googled a bit and tried some variations, such as:

command | tee /dev/tty | grep

But, no luck.

I don't want to use sth like

command
command | grep

as it is ugly :)

Thanks,

解决方案

Try

command | tee >(grep whatever)

Note that there's no space between these two symbols: >(.

这篇关于同时管道grep和重定向到标准输出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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