xargs reference
31 May 2023 (Updated 19 September 2023)
On this page
xargs is a Unix command-line utility that lets you convert input from standard input into an argument to a command.
Syntax
Here the output of <command1>
will be passed as an argument to <command-2>
Example
Assuming whoami
outputs “sajad” to standard input, xargs will take “sajad” and pass it as an argument to echo "I am logged in as:"
so that the command essentially becomes:
Another example
Combining xargs
with other commands like grep
or awk
lets you do things like:
This command will update all your NPM packages that contain fortawesome
in the package name. That’s quite handy.
Tagged:
Bash
Thanks for your comment . Once it's approved, it will appear here.
Leave a comment