On Fri, Jan 03, 2003 at 10:55:09AM -0500 Danny <[EMAIL PROTECTED]> wrote:
> Could you please give another realworld example of using xargs and
> your definition of it. I had a glance through man xargs, but I enjoy input
> from humans that use it as well. :)

Xargs is pretty neat.  You have to remember that there are different
implementations of it, too, so xargs on Linux would probably be
different than xargs on *BSD (it always is different in my experience).
The differences would mainly be in switches and default behavior.

I use xargs with lots of different utilities, just depending on what I
need to do with whatever files I'm catching.  For example, let's say I
wanted to rename some files:

locate *.PDF | xargs -I % mv % `basename % .PDF`.pdf

It's handy if you have a bunch of files in one directory that you want
to check somehow:

ls *.{jpg,gif} | xargs -J % file % | grep -v 'JPEG\|GIF'

Moving files to another directory is a popular use:

locate *.suf | xargs -J % mv % /path/to/dir

Note that you do not always need to use xargs.

locate *.PDF | while read name; do
mv $name ${name%.PDF}.pdf

There's lots more you can do with it.  Your imagination is almost your
only limitation.  :-)

David S. Jackson                        [EMAIL PROTECTED]
And now for something completely the same.

To Unsubscribe: send mail to [EMAIL PROTECTED]
with "unsubscribe freebsd-questions" in the body of the message

Reply via email to