home *** CD-ROM | disk | FTP | other *** search
/ SGI Developer Toolbox 6.1 / SGI Developer Toolbox 6.1 - Disc 4.iso / src / exampleCode / irix / scripts / edir < prev    next >
Encoding:
Text File  |  1994-08-02  |  1.2 KB  |  63 lines

  1. #!/bin/csh -f
  2. #
  3. # $Id: edir,v 1.1 93/08/20 13:19:12 carlson Exp $
  4. #
  5. # Description:
  6. #    This script will scan a directory and just list those files
  7. #    that are executable.
  8. #
  9. # Revision History:
  10. #    $Log:    edir,v $
  11. # Revision 1.1  93/08/20  13:19:12  carlson
  12. # Initial revision
  13. # Revision 1.1  1993/02/24  14:13:08  chris
  14. # Initial revision
  15. #
  16. #
  17. #-----------------------------------------------------------------------
  18.  
  19. if ( ! -e ~/bin/strlen ) then
  20.     echo "This script requires the program 'strlen' to run."
  21.     exit
  22. endif
  23.  
  24. set list = ()
  25. set i = 0
  26. foreach file ( * )
  27.     if ( -d $file ) continue
  28.     if ( -x $file ) then
  29.     set list = ( $list $file )
  30.     set a = `strlen $file`
  31.     if ( $a > $i ) set i = $a
  32.     endif
  33. end
  34.  
  35. if ( $i == 0 ) exit
  36.  
  37. #----
  38. # i        = Maximum size of word
  39. # columns    = Number of possible columns
  40. # rows        = Number of rows necessary
  41. #
  42.  
  43. @ i = $i + 2
  44. @ columns = 80 / $i
  45. @ rows    = ( $#list / $columns ) + 1
  46. set format = "%-${i}.${i}s"
  47.  
  48. @ row     = 0
  49.  
  50. while ( $rows > $row )
  51.     @ column = 0
  52.     while ( $columns > $column )
  53.     @ element = ( $row * $columns ) + $column + 1
  54.     if ( $element <= $#list ) then
  55.         printf "$format" $list[$element]\*
  56.     endif
  57.     @ column = $column + 1
  58.     end
  59.     echo ""
  60.     @ row = $row + 1
  61. end
  62.