ksh: Checking for file existence

Leslie Mikesell les at chinet.chi.il.us
Sat Jun 15 13:12:52 AEST 1991


In article <91165.101842RS0VRD at ROHVM1.BITNET> RS0VRD at ROHVM1.BITNET (Ross Druker) writes:
>I have what may be a trivial problem, but I haven't solved it yet.
>I'm using the Korn shell a script on an HP-UX system.  I would like
>to check for the existence of ANY data files, not a specific file.
>if test -r  *.data

This should work with sh or ksh:
FILES=`echo *.data`
if [ "*.data" = "$FILES" ]
  then :  # no match
else
  for i in $FILES
   do
  ... process them...
   done
fi

Les Mikesell
  les at chinet.chi.il.us



More information about the Comp.unix.shell mailing list