folding arguments

Rahul Dhesi dhesi at bsu-cs.UUCP
Sat Feb 13 01:14:46 AEST 1988


In article <120 at gsg.UUCP> lew at gsg.UUCP (Paul Lew) writes:
>     $ find $DIR -print | awk '{print "command",$0}' | sh	(flexible)
>or:
>     $ find $DIR -print | sed 's/^/command /' | sh		(fast)

Me, I prefer:

     $ find $DIR -exec command {} \;

However, the original poster wanted to give the command as many
arguments as possible, so it would be invoked less often, presumably
because efficiency was important to him.  Something like the original
fa, which folds argument lists into manageable size, is essential
in that case.  In a pinch I would try something like this:

     $ find $DIR -print | nroff | sed -e 's/  */ /g' | ...

Since nroff right-justifies by default, we use sed to squeeze multiple
blanks to a single blank so "while read" in sh will work.  (Not
tested.)
-- 
Rahul Dhesi         UUCP:  <backbones>!{iuvax,pur-ee,uunet}!bsu-cs!dhesi



More information about the Comp.unix.wizards mailing list