bashumerate
A fast command line tool for running the same command repeatedly over files, lines, ranges, or lists, built as a quicker alternative to xargs.
Bashumerate is a command line tool that helps you run the same command over and over on a list of items, such as a group of files, the lines of a text file, or a range of numbers. It is meant as a faster, easier to use alternative to older tools like xargs and find with the exec option, which are often used for this exact kind of repeated command running in a terminal.
You give the tool one of four kinds of input: a set of files matching a pattern, the lines from a file or from piped input, a numeric range like one to ten, or a plain list of items you type directly. Whatever you provide gets fed one at a time into a command you specify, with a placeholder symbol standing in for each individual item. For example, you could count the lines in every shell script in a folder, or download a list of web addresses one by one from a text file.
It also includes some extra conveniences: filtering which items get included or excluded by pattern, running commands in parallel instead of one at a time, a dry run mode that shows you what would happen without actually running anything, and a quiet mode that hides error messages. Developers can add entirely new kinds of input sources by writing a small shell script file, and the README shows an example that lists running Docker containers as a custom source.
According to the README's own benchmarks, run on a many core desktop processor, bashumerate is roughly ten to twenty five times faster than xargs for running a command on each of many items, mainly because it avoids writing temporary files and starting a new process for every single item. The project includes its own benchmark script so you can measure this on your own machine, and it ships with a test suite using the bats testing framework. It is written in shell script and released under the MIT license.
Where it fits
- Run the same shell command on every file matching a glob pattern.
- Loop over lines from a file or piped input, such as a list of URLs, and run a command on each.
- Iterate over a numeric range or a literal list of items in a shell script.
- Replace slower xargs or find -exec usage in scripts that process many items.