Re: Check for existence (style question)



Janis Papanagnou <Janis_Papanag...@xxxxxxxxxxx> wrote:
RonaldOttoValentinFischer wrote:
...

   if  ls mydir/*abc*   >/dev/null 2>&1
   then
       echo yes
   fi

This would fail on the Unices that have an ls(1) that does
not return non-zero return codes for nonexistent files/
directories; i.e. SunOS4 and others.

   set - mydir/*abc*
   [ -f "$1" ] && echo Yes

This is not a determinate test. If there is a file named
"*abc*", this test will also fail.

=Brian
.



Relevant Pages

  • Re: Check for existence (style question)
    ... not return non-zero return codes for nonexistent files/ ... If the requested action cannot be performed on an operand ... exit status shall be returned as non-zero. ...
    (comp.unix.shell)
  • Trouble formatting Excel data to be recognized when merged into Wo
    ... When merging these room numbers into Word the room numbers consistenting of ... alpha characters act as nonexistent. ... can only reliably merge the zip codes if there is an "error" in my Excel cell ...
    (microsoft.public.word.mailmerge.fields)
  • Re: What does this log mean?
    ... Status codes. ... Zero is no error occured, ... If you see non-zero you'll be seeing a ... To email, fix my address! ...
    (microsoft.public.inetserver.iis.smtp_nntp)
  • Re: Check for existence (style question)
    ... not return non-zero return codes for nonexistent files/ ... that any POSIX compliant ls should return a non-zero value. ...
    (comp.unix.shell)