[lug] bash scripting question

Hugh Brown hugh at math.byu.edu
Fri Nov 18 11:06:42 MST 2005



On Fri, 18 Nov 2005, Zan Lynx wrote:

> On Fri, 2005-11-18 at 08:45 -0700, Hugh Brown wrote:
> > I've had this problem a few times and haven't found a quick way to get
> > around it.  I often do per file operations at the bash prompt with
> > something like this:
> >
> > for i in `ls`; do
> > command $i| othercommand
> > done
>

> for i in *; do command "$i" | othercommand; done

>
> or
>
> find -maxdepth 1 -print0 | xargs -0 -i sh -c 'command {} | othercommand'


these both end up splitting on the space in the file name (it appears
that the null termination in find is gone by the time it gets to "sh -c").

Hugh



More information about the LUG mailing list