Sometimes we want to repeat a command on Linux, and we can use the following BASH function to repeat a command for a number of times: function repeat() { COUNT=$2 if ]; then COUNT=100 fi for i in $(seq 1 $COUNT); do echo Counter=$i: CMD=$1 if ! $1; then echo “Error! $i” return 1 fi done return 0 } TO use, this is an example: $ repeat “echo hello!” 10 The second parameter specifies the number of times to run, and by default it is 100 times. We can use this command to repeat some tests, to Continue Reading »
The post Simple Bash Function to Repeat a Command N times with Retries first appeared on Algorithms, Blockchain and Cloud.
Sometimes we want to repeat a command on Linux, and we can use the following BASH function to repeat a command for a number of times: function repeat() { COUNT=$2 if ]; then COUNT=100 fi for i in $(seq 1 $COUNT); do echo Counter=$i: CMD=$1 if ! $1; then echo “Error! $i” return 1 fi done return 0 } TO use, this is an example: $ repeat “echo hello!” 10 The second parameter specifies the number of times to run, and by default it is 100 times. We can use this command to repeat some tests, to Continue Reading »
The post Simple Bash Function to Repeat a Command N times with Retries first appeared on Algorithms, Blockchain and Cloud.
Related posts:
Recursive Combination Algorithm Implementation in C++ The combination is a frequently-used technique that choose a number of items from a whole…
How to Use the Dynamic Link Library in C++ Linux (gcc compiler)? The Dynamic Link Library (DLL) is stored separately from the target application and shared among…
What are the Differences between uBPF and eBPF? “uBPF” and “eBPF” are both related to BPF, which stands for Berkeley Packet Filter, a…
Introduction to 8-bit Famicom Clone – Subor – SB2000 Nintendo Entertainment System Family Game Console (often known as NES) was quite popular in 1980’s…
Using Peek function to read from Memory on BBG Famicom Clone on Basic Programming Language Most keyboards for famicom clones are not designed for games, but they are made for…
How to Kill a Process That Opens a TCP/UDP Port? Killing a process that opens a TCP port can be necessary in various situations, such…
Three Interesting/Fun BASH Commands This post shows you 3 interesting/fun BASH commands: BASH Console Tetris Game You can now…
Teaching Kids Programming – Reachable Nodes With Restrictions (Graph Theory, Union Find, Disjoint Set, Undirected/Unweighted Graph) Teaching Kids Programming: Videos on Data Structures and Algorithms There is an undirected tree with… Read More Algorithms, Blockchain and Cloud