[lug] bash scripting question
Hugh Brown
hugh at math.byu.edu
Fri Nov 18 11:10:25 MST 2005
On Fri, 18 Nov 2005, Stephen Queen wrote:
> On 11/18/05, Hugh Brown <hugh at math.byu.edu> 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
> >
> > The problem is that if the files have spaces in them, then things break.
> >
> > Is there some bash'ism that would allow me to get this to work.
> >
> >
> >
> > Hugh
> >
>
> How about
>
> oldifs=$IFS; IFS="" ; for i in `ls WinXP` ; do command "$i" |
> othercommand ; done ; export IFS=$oldifs
>
> Stephen
I had tried something like this before (using other random values for
IFS), but I get all of the files in the directory showing up as a single
argument to command.
Hugh
More information about the LUG
mailing list