Xargs

From PKC
Revision as of 16:33, 14 January 2022 by Benkoo (talk | contribs)
Jump to navigation Jump to search

xargs is a unix command for assigning various inputs to different other unix commands.

The nature of Function Connector

This command/program is particularly useful, and relevant to programming in general, because it is a way to redirect inputs from data pipes. In other words, it is a bridge between input sources and any chosen programs that can be run at the Unix command line.

Executing one line at a time

To execute commands for each of the line feed, use the following option:-n 1. For example:

ls | xargs -n 1 -i echo {}

Note that one must supply the -i option, so that {} can become the placeholder for content piped from the previous process.

Accepting special separators=

In certain cases, when the input data embeds separators, one needs to turn on the -0 option. For example:

ls | xargs -0 -n 1 cp {} /targetDirectory

Related Pages

Video/HOW TO USE Xargs!!! Linux Core Utils, Video/Intro to xargs, Video/Xargs Should Be In Your Command Line Toolbag, Video/all about xargs ! (beginner - intermediate) anthony explains, Xargs