Date: Fri, 3 Jan 2003 14:04:33 -0500 From: "David S. Jackson" <deepbsd@earthlink.net> To: Danny <lists@brenius.com> Cc: questions@FreeBSD.ORG, deepbsd@earthlink.net Subject: Re: Shell guru needed.(xargs question) Message-ID: <20030103190433.GB1925@sylvester.dsj.net> In-Reply-To: <003301c2b340$7e473570$7801a8c0@afi> References: <200301030103.h0313b67012698@labs.unixhideout.com> <20030103152501.GA1925@sylvester.dsj.net> <003301c2b340$7e473570$7801a8c0@afi>
next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Jan 03, 2003 at 10:55:09AM -0500 Danny <lists@brenius.com> 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 done There's lots more you can do with it. Your imagination is almost your only limitation. :-) -- David S. Jackson dsj@dsj.net =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-= And now for something completely the same. To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-questions" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030103190433.GB1925>