[Linux-disciples] Portability and `ls`

Stephen R Laniel steve at laniels.org
Wed Feb 8 14:45:29 EST 2006


I see a lot of shell scripts that use something like

for i in `ls dirName`

when in that case I would just use

for i in dirName/*

Is there any reason to use the earlier syntax? I thought
maybe there was a portability issue there, and that maybe
the latter didn't work under /bin/sh -- that maybe the
latter was a bashism. But I just made a little shell script
that uses the latter syntax, and all is well.

So is there any good reason to use 'for i in `ls dirName`'?
I would dismiss it out of hand, but I just realized
yesterday that there are sound reasons to use

cp /dev/null filename

when I previously dismissed *that*. So I'm wary of
dismissal.

-- 
Stephen R. Laniel
steve at laniels.org
+(617) 308-5571
http://laniels.org/
PGP key: http://laniels.org/slaniel.key
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: Digital signature
Url : http://lists.bostoncoop.net/pipermail/linux-disciples/attachments/20060208/754c70ce/attachment.pgp


More information about the Linux-disciples mailing list