Digital Communication


Digital Communication

xargs: convert standard input to commands


With Linux xargs, turn standard input into commands and use them directly. Although the xargs command is not often used in Linux, it can greatly simplify your work.

What is the xargs command?

The xargs command stands for “extended arguments”. It is one of the Linux commands that are never, or rarely, applied by the majority of users. However, the command can considerably simplify the work and, depending on the case, can even protect your computer. In a simplified manner, Linux xargs links two commands by exploiting the result of the first which it applies to the second. This is particularly useful when you need to process a large number of files and perform specific tasks repeatedly.

The xargs command is included in the majority of Linux distributions, such as Debian or Ubuntu, so there is no need to install it.

How does the xargs command work?

xargs reads data from stdin (the input data) and converts them to command lines. The corresponding instruction must therefore be supplied to the command in the form of a parameter or an argument. The respective commands are then executed one or more times. If you forgo specifying a special command as a parameter, xargs automatically uses the echo command.

What is the syntax of Linux xargs?

If you want to use the xargs command on the terminal, follow the following syntax:

$ Première_commande| xargs [Options] [Deuxième_commande]


The second command is executed with the arguments of the first command.

What are the options for the xargs command?

The Linux xargs command has many options. Here are the main ones:

  • -0 or –null : with this option, each character is used literally and the arguments are separated by null characters.
  • -a or –arg-file : with this option, the arguments are not read from standard input, but from a file.
  • -d or –delimiter : with this option, separations are based on hyphens and not spaces. Also in this case each character is used literally.
  • -p or –interactive : Before each execution, this option asks if xargs should continue.

Examples of using Linux xargs

The best way to explain how the xargs command works is to show a few examples.

$ find -name "*.txt" | xargs rm


In this example, you combine xargs with the find command and the rm command. The result of this example is that all files with the extension .txt in the computer’s file system are excluded.

$ find -name "*.txt" | xargs grep "ordinateur"


With this command you search for all files that contain the word “computer”. To do this, you also need to use the grep command.

Télécharger notre livre blanc

Comment construire une stratégie de marketing digital ?

Le guide indispensable pour promouvoir votre marque en ligne

En savoir plus

Souhaitez vous Booster votre Business?

écrivez-nous et restez en contact