Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

create infinite looping repeating file cat in linux/bash

Tags:

linux

bash

cat

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?

like image 982
rogerdpack Avatar asked Jan 01 '16 10:01

rogerdpack


People also ask

How do you make an infinite loop in Linux?

The following syntax is used for create infinite while loop in a shell script. echo "Press [CTRL+C] to exit this loop..." You can also Unix true command with while loop to run it endlessly. The while loop syntax with true command will look like below example.

Can you have an infinity loop in bash?

An infinite loop in Bash or any other programming language refers to a loop that is continuous i.e., its terminating condition is never met or its executing condition forever stays true. Such loops in any programming language are very simple to write.

How do you create a loop in Linux?

Basic structure of the for loop The basic syntax of a for loop is: for <variable name> in <a list of items>;do <some command> $<variable name>;done; The variable name will be the variable you specify in the do section and will contain the item in the loop that you're on.


1 Answers

The yes command, using the file's contents as it's argument:

yes "$(<file)" | somecommand
like image 165
glenn jackman Avatar answered Sep 26 '22 19:09

glenn jackman