Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/whiteblackgoose/forall.bash
Simple bash command which maps the given list of elements through the given command
https://github.com/whiteblackgoose/forall.bash
Last synced: 18 days ago
JSON representation
Simple bash command which maps the given list of elements through the given command
- Host: GitHub
- URL: https://github.com/whiteblackgoose/forall.bash
- Owner: WhiteBlackGoose
- License: cc0-1.0
- Created: 2022-08-28T08:42:22.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2022-08-28T10:31:21.000Z (about 2 years ago)
- Last Synced: 2024-10-19T18:47:12.497Z (30 days ago)
- Language: Shell
- Size: 59.6 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# forall
![demo](./demo-x1.6.gif)
## Installation
Download and make it executable:
```
wget https://raw.githubusercontent.com/WhiteBlackGoose/forall.bash/main/forall
chmod +x forall
```Add it to your "$PATH":
```
echo 'export PATH="yourfolder:$PATH"' >> ~/.bashrc
```## Docs
```
Automates simple loops. Basically maps the given
elements through the given function.The first argument is list of elements (must be o
ne argument, not multiple).The second argument is the command to execute (al
so must be one string).By default it only executes the given command, by
providing each element of the list as the last ar
gument.Arguments (provide as third argument without dash):
i: provide each element as standard input inste
ad of providing it as the last argument.p: print the each element next to correspondi
ng output. (by default only runs the prompt)
```## Examples
### Ex. 1
```
forall "$(ls -Cb)" "du -sh"
```Runs the command `du -sh` for all folders in the given folder:
```
~/VirtualBox VMs
12:06:29 $ forall "$(ls -Cb)" "du -sh"
6,7G archcraft
11G Linux Mint
8,0K test
88K ubuntu 4.10
9,2G ubuntu mate
```### Ex. 2
```
forall "10+3 12-11 'scale=3; 100/3'" bc i
````i` means that we pipe each element into the given command `bc`. Output:
```
~/VirtualBox VMs
12:38:02 $ forall "10+3 12-11 'scale=3; 100/3'" bc i
13
1
33.333
```### Ex. 3
Let's add `p` to print each input:
```
forall "10+3 12-11 'scale=3; 100/3'" bc ip
```Output:
```
~/VirtualBox VMs
12:38:50 $ forall "10+3 12-11 'scale=3; 100/3'" bc ip
10+3: 13
12-11: 1
scale=3; 100/3: 33.333
```