在linux/bash中创建无限循环重复文件cat [英] create infinite looping repeating file cat in linux/bash

查看:339
本文介绍了在linux/bash中创建无限循环重复文件cat的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想做的是重复地"发送一个文件(就像无数次地整理文件一样)作为另一个程序的输入.在命令行上/使用bash有办法吗?

What I'd like to do is send a single file "repeatedly" (like cat'ing it an infinite number of times) as input to another program. Is there a way on the command line/using bash?

推荐答案

流程替换提供了一种机制,通过该机制bash可以为您生成连接到任意bash代码块的可读的临时文件名:

Process substitution provides a mechanism by which bash can generate a temporary, readable filename connected to an arbitrary chunk of bash code for you:

./my_program -input <(while cat file_to_repeat; do :; done)

这将在支持它的操作系统上创建一个/dev/fd/NN样式的名称,否则将创建一个命名管道.

This will create a /dev/fd/NN-style name on operating systems that support it, or a named pipe otherwise.

这篇关于在linux/bash中创建无限循环重复文件cat的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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