LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - General (https://www.linuxquestions.org/questions/linux-general-1/)
-   -   Using xargs (https://www.linuxquestions.org/questions/linux-general-1/using-xargs-632633/)

SBN 04-03-2008 02:34 AM

Using xargs
 
Hey guys i have a hard time understanding xargs, what is it and what does it do?

Zmyrgel 04-03-2008 02:47 AM

You can pipe a list of arguments to xargs which can apply other commands to it.

Code:

find $HOME -name *.jpg | xargs ls -l
Makes a detailed list of jpg files in home directory by applying 'ls -l' to all files found by find.

You could use find's '-exec' option above but xargs is faster than that.

Tinkster 04-07-2008 07:44 PM

And to explain the WHY of xargs ... when you have a direcotry with MANY
files, and use shell globbing of sorts you may encounter errors a la
"argument list too long" or "too many arguments".

xargs allows you to work around that.



Cheers,
Tink


All times are GMT -5. The time now is 02:35 PM.