diff --git a/knowledge base/xargs.md b/knowledge base/xargs.md index dd8b0e3..79aecc8 100644 --- a/knowledge base/xargs.md +++ b/knowledge base/xargs.md @@ -1,11 +1,14 @@ # `xargs` -## Table of contents - 1. [TL;DR](#tldr) +1. [Further readings](#further-readings) + 1. [Sources](#sources) ## TL;DR +
+ Usage + ```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 %% ``` +
+ +## Further readings + +- [An Opinionated Guide to xargs] + +### Sources + +- [xargs: exec command with prompt] + + + + + + + + [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