Crates.io | parallel-sh |
lib.rs | parallel-sh |
version | 0.2.0 |
source | src |
created_at | 2021-04-04 21:17:11.165661 |
updated_at | 2024-09-09 16:28:15.285851 |
description | Execute commands in parallel |
homepage | https://crates.io/crates/parallel-sh |
repository | https://github.com/thyrc/parallel-sh |
max_upload_size | |
id | 378966 |
size | 24,278 |
parallel-sh
was heavily inspired by Rust Parallel (parallel) parallelizing 'otherwise non-parallel command-line tasks.' But instead of trying to recreate the full functionality of GNU Parallel parallel-sh
will simply execute (lines of) commands in the platform's preferred shell (by default 'sh -c' on Unix systems, and 'powershell.exe -c' on Windows) in separate threads.
What to expect:
What is not part of parallel-sh
:
--file
option and stdin are ignored.--file
is provided anything on stdin is ignored.parallel-sh 'ls -1 |wc -l
or parallel-sh.exe "Get-ChildItem -Path * | Measure-Object -Line"
Most of the effects of these features can be achieved by processing the commands before passing them to parallel-sh
.
parallel-sh 0.1.14
Execute commands in parallel
Usage: parallel-sh [OPTIONS] [clijobs]...
Arguments:
[clijobs]...
Options:
-q, --quiet Do not print `parallel-sh` warnings
-n, --dry-run Perform a trial run, only print what would be done (with -vv)
-v, --verbose... Sets the level of verbosity
-l, --log <FILE> Log output to file
--halt-on-error Stop execution if an error occurs in any thread
-j, --jobs <THREADS> Number of parallel executions
-s, --shell <SHELL> Shell to use for command execution. Must support '-c' (defaults to sh)
--no-shell Do not pass commands through a shell, but execute them directly
-f, --file <FILE> Read commands from file (one command per line)
-h, --help Print help
-V, --version Print version
Per default commands are executed via
With --no-shell
the commands are started without passing them through a shell. This will avoid the overhead of starting a shell in each thread, but you will lose features like quotes, escaped characters, word splitting, glob patterns, variable substitution, etc.
The commands inherit parallel-sh
’s working directory.
Pass commands as arguments:
parallel-sh "sleep 2 && echo first" "sleep 1 && echo second"
Pass a file with one command (-line) per line:
parallel-sh -f /tmp/commands
$ cat /tmp/commands
sleep 2 && echo first
sleep 1 && echo second
Pass commands via stdin:
echo -e 'sleep 2 && echo first\nsleep 1 && echo second' |parallel-sh