From 5f4b82389abe442c8108cbd832332be7efe057d6 Mon Sep 17 00:00:00 2001 From: Michele Cereda Date: Tue, 5 Dec 2023 18:20:26 +0100 Subject: [PATCH] chore: use shell aliases in xargs --- knowledge base/xargs.md | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/knowledge base/xargs.md b/knowledge base/xargs.md index 1989384..951de15 100644 --- a/knowledge base/xargs.md +++ b/knowledge base/xargs.md @@ -20,4 +20,10 @@ find ~ -type f -printf "'%p' " | xargs -P 5 -n 1 clamscan # replace a given string with arguments read from input # useful to insert the arguments in the middle of the command to execute find ~ -type d -name ".git" -exec dirname {} + | xargs -I // git -C "//" pull + +# Use aliases as commands. +# The 'BASH_ALIASES' array works only in BASH. +# 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'] ```