Using the xargs command on Linux to simplify your work

The xargs command on Linux can make it easier to build and execute commands. If you want to run the same command for a group of files or users, xargs can often make that process easier. Here’s a very simple example of xargs that creates or updates the update time on some files.

$ echo file1 file2 file3 | xargs touch
$ ls -l
total 0
-rw-r–r–. 1 shs shs 0 Oct 15 12:41 file1
-rw-r–r–. 1 shs shs 0 Oct 15 12:41 file2
-rw-r–r–. 1 shs shs 0 Oct 15 12:41 file3

The command below is similar, but creates a file with blanks in its name because the -d specifies the input termination character.

To read this article in full, please click here

Source:: Network World – Linux