home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 11 Util / 11-Util.zip / MAWK113.ZIP / mawk113 / msdos / examples / doslist.awk < prev    next >
Text File  |  1992-12-05  |  545b  |  35 lines

  1.  
  2. # print truncated DOS file names
  3. # from packing.list (packing.lis)
  4. #
  5. #  mawk -f doslist.awk packing.lis
  6.  
  7.  
  8. # discard blanks and comments
  9. /^#/ || /^[ \t]*$/ {next}
  10.  
  11.  
  12. function dos_name(s,    n, front, X)
  13. {
  14.   #lowercase, split on extension and truncate pieces
  15.   s = tolower(s)
  16.   n = split(s, X, ".")
  17.  
  18.   front = substr(X[1],1,8)
  19.  
  20.   if ( n == 1 )  return front
  21.   else return front "." substr(X[2], 1, 3)
  22. }
  23.  
  24. {
  25.   n = split($1, X, "/")
  26.   new = dos_name(X[1])
  27.  
  28.   for( i = 2 ; i <= n ; i++ )
  29.     new = new "\\" dos_name(X[i])
  30.  
  31.   printf "%-30s%s\n", $1, new
  32. }
  33.  
  34.  
  35.