[H-GEN] Useful not so obvious tips

Greg Black gjb at gbch.net
Mon Oct 25 05:18:52 EDT 2004


On 2004-10-25, ben.carlyle at invensys.com wrote:

> If I'm reading http://members.cox.net/bob.weeks/articles/hm50.htm 
> correctly and it is to be trusted, doskey was introduced into dos 5.0 
> (around the time of Windows 3.0).

It was around when DOS-3.1 was the latest and 8088 CPUs were
cool ...

> Now to make this unix-related:
> 
> To pick up the xargs point, lets take David's find -exec example and 
> convert it to use xargs:
> $ find . -type f -exec do_something_interesting {} \;
> becomes
> $ find . -type f | xargs do_something_interesting
> 
> Simple, as long as your do_something application accepts more than one 
> filename as a parameter. xargs will hand a "reasonable" number of 
> parameters to each execution, while keeping in mind limits on the length 
> of the command line for overly-long filenames. It can be more efficient. 
> Instead of starting one invocation for each file, you might get half a 
> dozen or more into one invocation. Be warned, however: Weird filenames 
> (such as those containing spaces) can upset xargs when used in this mode.

This is why god invented the -print0 option for find and the -0
option for xargs -- there's a case for making them the defaults,
certainly in one's typing fingers.

And reading of the man pages for both find and xargs should be
something you do at least once every couple of months, at least
until you actually know all the stuff that they can do.

Cheers, Greg




More information about the General mailing list