重复简单的方式读取线和调用程序 [英] Simpler way to repeatedly read lines and invoke a program

查看:82
本文介绍了重复简单的方式读取线和调用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想反复读取一行并调用程序以线的说法,实际上,使得非交互式节目互动。

有没有更简单或更短的方式比这个?

 而读线;做
  cowsay $线
DONE


解决方案

试试这个:

  xargs的-d的'\\ n'-n 1 cowsay

I'd like to repeatedly read a line and invoke a program with the line as the argument—in effect, making a non-interactive program interactive.

Is there a simpler or shorter way than this?

while read line; do
  cowsay $line
done

解决方案

Try this:

xargs -d '\n' -n 1 cowsay

这篇关于重复简单的方式读取线和调用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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