<span>I might prefer 'find' instead of 'ls' if there's a limit with 'ls'. There's also a glob limit in most shells, which may be a consideration here. (I.e., if you have more than 1000(??) *.bad files, the shell will die before even calling 'ls'.)
<br><br>Using 'find' might turn it into:<br><br>if [ 'find . -name "*.bad" -maxdepth 1 | wc -l` ]<br><br>The 'maxdepth' argument won't work on systems without GNU find, I believe. You may or may not need it, depending on whether you have subdirectories you don't want to search.
<br><br>If that doesn't work, I would most definitely turn to Perl/</span><span>Ruby/</span><span>Python/TCL/.../Java/D/C/C++/C#.<br><br>Also, while it's good practice to send stderr to /dev/null,it shouldn't be at all necessary here. I don't know of any shells which pass stderr through a pipe unless explicitly directed to do so (
e.g., "2>&1")<br><br>Chris<br></span><br><div class="gmail_quote">On Dec 20, 2007 4:15 PM, Jerry Heiselman <<a href="mailto:jweida@gmail.com">jweida@gmail.com</a>> wrote:<br><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
<div class="Ih2E3d">On 12/20/07, Matthew Nuzum <<a href="mailto:newz@bearfruit.org">newz@bearfruit.org</a>> wrote:<br>> On Dec 20, 2007 1:58 PM, Major Stubble <<a href="mailto:major.stubble@gmail.com">major.stubble@gmail.com
</a>> wrote:<br>><br>> > It is the default shell for Solaris. Other Unix systems have some<br>> > version of it available. Linux and BSD typically have pfksh, which<br>> > to my eyes seems less restrictive than the pure ksh's of the Unix world.
<br>> ><br>> > I myself will typically use sh before ksh or bash for most scripts<br>> > since it is the most restrictive of all. That said, I won't work in<br>> > a shell environment without my vi keys, so if I am working in bash,
<br>> > it have to 'set -o vi'.<br>> ><br>> > All that said, I have never been on a Unix system without ksh. It is<br>> > also true that I have not been on a Linux system without bash.<br>
> ><br>><br><br></div>It may be beneficial to use the POSIX certified shell on the system,<br>which you should always be able to find by setting your PATH to the<br>result of `getconf PATH`. The first shell found will always be POSIX
<br>compliant and should behave the same on all systems.<br><br>That said, I would probably use the solution utilizing the ls *.bad<br>2>/dev/null | wc -l approach. It does spawn two external programs,<br>but the impact in this instance should be pretty negligible. Of
<br>course, this runs into a problem on most Solaris machines in that if<br>you have more than 250 (I think this is the limit) files, then ls will<br>puke because it has an upper limit. Unfortunately, there really isn't
<br>a good fix for this except to use another language such as Perl or<br>Python. If you are in this situation, then you will have to go with a<br>for loop as it acts more like an iterator.<br><font color="#888888"><br>--
<br>Jerry H<br></font><div><div></div><div class="Wj3C7c">_______________________________________________<br>Cialug mailing list<br><a href="mailto:Cialug@cialug.org">Cialug@cialug.org</a><br><a href="http://cialug.org/mailman/listinfo/cialug" target="_blank">
http://cialug.org/mailman/listinfo/cialug</a><br></div></div></blockquote></div><br>