home *** CD-ROM | disk | FTP | other *** search
/ Aminet 10 / aminetcdnumber101996.iso / Aminet / util / gnu / groff_src.lha / groff-1.10src / mdate.sh < prev    next >
Linux/UNIX/POSIX Shell Script  |  1992-09-25  |  921b  |  42 lines

  1. #! /bin/sh
  2.  
  3. # Print the modification date of $1 `nicely'.
  4.  
  5. # Don't want foreign dates.
  6.  
  7. LANGUAGE=
  8.  
  9.  
  10. (date;
  11. if ls -L /dev/null 1>/dev/null 2>&1; then ls -L -l $1; else ls -l $1; fi
  12. ) | awk '
  13. BEGIN {
  14.     full["Jan"] = "January"; number["Jan"] = 1;
  15.     full["Feb"] = "February"; number["Feb"] = 2;
  16.     full["Mar"] = "March"; number["Mar"] = 3;
  17.     full["Apr"] = "April"; number["Apr"] = 4;
  18.     full["May"] = "May"; number["May"] = 5;
  19.     full["Jun"] = "June"; number["Jun"] = 6;
  20.     full["Jul"] = "July"; number["Jul"] = 7;
  21.     full["Aug"] = "August"; number["Aug"] = 8;
  22.     full["Sep"] = "September"; number["Sep"] = 9;
  23.     full["Oct"] = "October"; number["Oct"] = 10;
  24.     full["Nov"] = "November"; number["Nov"] = 11;
  25.     full["Dec"] = "December"; number["Dec"] = 12;
  26. }
  27.  
  28. NR == 1 {
  29.     month = $2;
  30.     year = $NF;
  31. }
  32.  
  33. NR == 2 {
  34.     if ($(NF-1) ~ /:/) {
  35.         if (number[$(NF-3)] > number[month])
  36.             year--;
  37.     }
  38.     else
  39.         year = $(NF-1);
  40.     print $(NF-2), full[$(NF-3)], year
  41. }'
  42.