在OsX下相当于xargs -r是什么 [英] What is the equivalent to xargs -r under OsX

查看:102
本文介绍了在OsX下相当于xargs -r是什么的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

它们在OSX下是否等同于Linux下的xargs -r?我正在尝试找到一种方法来在没有数据的情况下中断管道.

Are they any equivalent under OSX to the xargs -r under Linux ? I'm trying to find a way to interupt a pipe if there's no data.

例如,假设您执行以下操作:

For instance imagine you do the following:

touch test
cat test | xargs -r echo "content: "

这不会产生任何结果,因为xargs中断了管道.

That doesn't yield any result because xargs interrupts the pipe.

是否存在某些 hidden xargs选项或其他在OSX下达到相同结果的东西?

Is there either some hidden xargs option or something else to achieve the same result under OSX?

推荐答案

您可以使用test[:

if [ -s test ] ; then cat test | xargs echo content: ; fi

这篇关于在OsX下相当于xargs -r是什么的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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