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

Re: Need some shell scripting help

> 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)
> I'd go with $(find . -maxdepth 1) or something, instead of ls. You
> could even play with find . -maxdepth 1 -exec echo {} \;, or find
> . -maxdepth 1 | xargs echo

That will also pick up dotfiles, whereas relying on ls output
or globbing would not (unless you've mucked with defaults).

I prefer

print -l *

Reply to: