chore(kb/xargs): retain interactive mode

This commit is contained in:
Michele Cereda
2024-09-28 18:47:38 +02:00
parent 86bb0c9f3e
commit b7652fcc79

View File

@@ -1,11 +1,14 @@
# `xargs`
## Table of contents <!-- omit in toc -->
1. [TL;DR](#tldr)
1. [Further readings](#further-readings)
1. [Sources](#sources)
## TL;DR
<details>
<summary>Usage</summary>
```sh
# print the command to be executed and immediately start it
echo 1 2 3 4 | xargs -t mkdir
@@ -26,6 +29,32 @@ find ~ -type d -name ".git" -exec dirname {} + | xargs -I // git -C "//" pull
# The 'aliases' array works only in ZSH.
echo 1 2 3 4 | xargs "${BASH_ALIASES[my-alias]}"
echo 1 2 3 4 | xargs $aliases['my-alias']
# Execute interactive commands.
# Reopen the TTY with '-o', '--open-tty'.
grep -lz PATTERN * | xargs -0o vi
find '.' -type 'f' -name 'Pulumi.yaml' -not -path "*/node_modules/*" -exec dirname {} '+' | xargs -otI%% pulumi up -C %%
```
</details>
## Further readings
- [An Opinionated Guide to xargs]
### Sources
- [xargs: exec command with prompt]
<!--
Reference
═╬═Time══
-->
<!-- In-article sections -->
<!-- Knowledge base -->
<!-- Files -->
<!-- Upstream -->
<!-- Others -->
[an opinionated guide to xargs]: https://www.oilshell.org/blog/2021/08/xargs.html
[xargs: exec command with prompt]: https://stackoverflow.com/questions/30044927/xargs-exec-command-with-prompt#69590861