Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wickdchromosome/prl
Easily execute shell commands in parallel
https://github.com/wickdchromosome/prl
Last synced: 26 days ago
JSON representation
Easily execute shell commands in parallel
- Host: GitHub
- URL: https://github.com/wickdchromosome/prl
- Owner: wickdChromosome
- License: mit
- Created: 2022-08-15T18:06:24.000Z (about 2 years ago)
- Default Branch: master
- Last Pushed: 2022-09-11T17:06:26.000Z (about 2 years ago)
- Last Synced: 2024-03-12T15:29:09.486Z (8 months ago)
- Language: Go
- Homepage:
- Size: 3.32 MB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# prl -> Easy sh command parallelization
![prl demo](demo.gif)
## Examples
#### Zip all files in current directory
```
prl --cmd "zip -r '{ls .}.zip' '{ls .}'"
```#### Just print the generated commands, without execution
```
prl --dry-run --cmd "zip -r '{ls .}.zip' '{ls .}'"
```#### Execute commands, but don't print text returned by commands to stdout(but still show progress bar)
```
prl -s --cmd "zip -r '{ls .}.zip' '{ls .}'"
```#### Same as above, but set custom text for progress bar
```
prl -s --progbar-string "Zipping files.." --cmd "zip -r '{ls .}.zip' '{ls .}'"
```#### Get file sizes for all zipped pdf files in the Downloads folder, using 6 parallel processes
```
prl -j 6 --cmd "du -h '{ ls ~/Downloads/*.zip | grep pdf }'"
# don't forget the the two quotes(') around the command - that way spaces etc in filenames are correctly handled
```
#### Get list of active hosts in IP range using ping, using 12 processes, into a file(hosts.txt)
```
prl -s -j 12 --cmd "ping -c 1 192.168.0.{seq 0 100} && echo 192.168.0.{seq 0 100} UP >> hosts.txt || echo 192.168.0.{seq 0 100} DOWN >> hosts.txt" --progbar-string "Pinging hosts.."
```## Arguments
- -j -> The number of concurrent processes to execute the command over
- --cmd -> A string of the command to execute.
- --progbar-string -> Set custom text for your progress bar
- -s -> Silent mode, don't print text returned from commands to stdout(but still show progbar)
- --dry-run -> Print out generated commands to be executed, but don't actually execute them
- --help -> Print help msgThe command string should have commands to parallelize over in parantheses -> {}
The results of this command should result in a list of arguments, separated by newline(\n)
prl will execute the supplied command in parallel, substituting the arguments into the place of the parantheses## Simple example
```
prl -j 2 -cmd "ls '{ls /home}'"
```
Where /home contains:
```
/home/user1
/home/user2
```
The commands executed concurrently will be:
```
ls '/home/user1'
ls '/home/user2'
```
But this can be used for any shell command.## TODO
- Better logging, where all the output is captured and sorted by command
- Many, many more tests