Skip to content

Commit

Permalink
xargs: initial notes
Browse files Browse the repository at this point in the history
  • Loading branch information
johannst committed Nov 16, 2024
1 parent b9d649c commit deb4619
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/SUMMARY.md
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
- [tac](./cli/tac.md)
- [rev](./cli/rev.md)
- [paste](./cli/paste.md)
- [xargs](./cli/xargs.md)

- [Tools](./tools/README.md)
- [tmux](./tools/tmux.md)
Expand Down
1 change: 1 addition & 0 deletions src/cli/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,3 +9,4 @@
- [tac](./tac.md)
- [rev](./rev.md)
- [paste](./paste.md)
- [xargs](./xargs.md)
23 changes: 23 additions & 0 deletions src/cli/xargs.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# xargs(1)

```
xargs [opts] [cmd [init-args]]
-l [<num>] maximal number of lines per cmd invocation
if <num> it not provided, num=1 is assumed
-I <str> replace <str> in the [init-args] with the arg;
this implies -l, and hence processes one arg at a time
```

## Example

Collect arguments and prefix them with another option.
```sh
# Using -l to process one arg at a time.
eval strace -f (find /dev -name 'std*' | xargs -l echo -P | xargs) ls

# Using -I to place the arg at the specified location.
eval strace -f (find /dev -name 'std*' | xargs -I {} echo -P {}) ls

# Both commands achieve the same thing and result in something like:
# eval strace -f -P /dev/stdin -P /dev/stdout -P /dev/stderr ls
```

0 comments on commit deb4619

Please sign in to comment.