[Cialug] [OT]: Shell script globbing

Jerry Heiselman jweida at gmail.com
Thu Dec 20 16:15:05 CST 2007


On 12/20/07, Matthew Nuzum <newz at bearfruit.org> wrote:
> On Dec 20, 2007 1:58 PM, Major Stubble <major.stubble at gmail.com> wrote:
>
> > It is the default shell for Solaris.  Other Unix systems have some
> > version of it available.  Linux and BSD typically have pfksh, which
> > to my eyes seems less restrictive than the pure ksh's of the Unix world.
> >
> > I myself will typically use sh before ksh or bash for most scripts
> > since it is the most restrictive of all.  That said, I won't work in
> > a shell environment without my vi keys, so if I am working in bash,
> > it have to 'set -o vi'.
> >
> > All that said, I have never been on a Unix system without ksh.  It is
> > also true that I have not been on a Linux system without bash.
> >
>

It may be beneficial to use the POSIX certified shell on the system,
which you should always be able to find by setting your PATH to the
result of `getconf PATH`.  The first shell found will always be POSIX
compliant and should behave the same on all systems.

That said, I would probably use the solution utilizing the ls *.bad
2>/dev/null | wc -l approach.  It does spawn two external programs,
but the impact in this instance should be pretty negligible.  Of
course, this runs into a problem on most Solaris machines in that if
you have more than 250 (I think this is the limit) files, then ls will
puke because it has an upper limit.  Unfortunately, there really isn't
a good fix for this except to use another language such as Perl or
Python.  If you are in this situation, then you will have to go with a
for loop as it acts more like an iterator.

-- 
Jerry H


More information about the Cialug mailing list