The xargs Utility

Learn about the xargs utility in detail.

We'll cover the following

xargs

We can use a pipeline and get the -exec action behavior. We should apply the xargs utility for that.

Let’s go through an example. Let’s suppose that we want to find a pattern in the contents of the found files. In this case, the grep utility should receive file paths, but not the plain text. We can apply the pipeline and xargs to solve this task. The solution looks like this:

find ~ -type f | xargs grep "bash"

This command cannot handle files whose names contain spaces and line breaks. We will learn how to solve this problem in later lessons.

Run the commands discussed in this lesson in the terminal below.

Get hands-on with 1200+ tech skills courses.