[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: Need some shell scripting help

On Fri, Dec 14, 2001 at 07:58:31PM -0500, Clint Adams wrote:
> > for item in $(ls); do
> > 	echo "${item}"
> > done
> That doesn't buy you much over shell globbing.
> for item in * ; do echo "${item}" ; done
> will do the same thing.  And both will break if
> your shell happens to respect $IFS and there are
> IFS-characters in your file names (like spaces,
> for instance)

Surely shell globbing automatically escapes specials?

jules@pear [7] cd temp
jules@pear [8] touch "A B"
jules@pear [9] touch "A&B"
jules@pear [10] touch "A;B"
jules@pear [11] ls
A B  A&B  A;B
jules@pear [12] for item in *; do echo $item; done                      

works for me (TM)

I think bash does respect IFS, but I think that globbing knows about it..

("for item in `ls`; do echo $item; done" does get tripped up by the
space, though)


Reply to: