From the course: Linux Tips

Unlock this course with a free trial

Join today to access over 22,400 courses taught by industry experts.

Using xargs

Using xargs - Linux Tutorial

From the course: Linux Tips

Using xargs

- [Instructor] Xargs takes information from standard input and converts it to arguments that can be used in a command. In most cases, it's used to take a list of some kind and use each item in that list as an argument for a command. While it can seem a little bit exotic at first, xargs allows us to do some pretty powerful things. Let's look at copying files as a specific example. If we wanted to copy all the files in a folder that match certain criteria somewhere else, that's pretty easy. We'd just say cp, and then an expression describing what files we want to copy to somewhere. But what if we wanted to copy files that match certain criteria from anywhere on the system to that folder? The cp command isn't clever enough to go out and find things, but the find command is, and the find command returns a list of things that match given criteria. So we can pretty easily find things, but how do we get that list of results into…

Contents