Table of Contents
Previous Utility | List of External Utilities | Next Utility

Whereis.csh


#  whereis.csh, Release 2.2

#  Look through the directories on the search path for any files corresponding
#  to the command name given, reporting anything that's found.  If no .ext
#  file type extension is given as part of the name, try each of the five
#  possibilities, .csh, .exe, .com, .cmd and .bat, in each directory.

#  This is an example of a self-loading procedure.  The first time
#  it is referenced, it runs as a .csh script, defining and running
#  the whereis proc.  Successive calls directly invoke the pre-compiled
#  procedure and will run slightly faster. (View this file with TABS=3.)

proc whereis(name)
   local i, j
   if (name =~ "*.*") then
      foreach i ($path)
         if (i =~ "*\") then
            if (-e $i$name) echo $i$name
         else
            if (-e $i\$name) echo $i\$name
         end
      end
   else
      foreach i ($path)
         if (i =~ "*\") then
            foreach j (.csh .exe .com .cmd .bat)
               if (-e $i$name$j) echo $i$name$j
            end
         else
            foreach j (.csh .exe .com .cmd .bat)
               if (-e $i\$name$j) echo $i\$name$j
            end
         end
      end
   end
end

whereis $argv



Previous Utility | List of External Utilities | Next Utility
Table of Contents



Copyright © 1988-2003 by Hamilton Laboratories. All rights reserved.