[3124] | 1 | #!/bin/sh
|
---|
| 2 | # Get modification time of a file or directory and pretty-print it.
|
---|
| 3 | # Copyright (C) 1995, 1996, 1997 Free Software Foundation, Inc.
|
---|
| 4 | # written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
|
---|
| 5 | #
|
---|
| 6 | # This program is free software; you can redistribute it and/or modify
|
---|
| 7 | # it under the terms of the GNU General Public License as published by
|
---|
| 8 | # the Free Software Foundation; either version 2, or (at your option)
|
---|
| 9 | # any later version.
|
---|
| 10 | #
|
---|
| 11 | # This program is distributed in the hope that it will be useful,
|
---|
| 12 | # but WITHOUT ANY WARRANTY; without even the implied warranty of
|
---|
| 13 | # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
---|
| 14 | # GNU General Public License for more details.
|
---|
| 15 | #
|
---|
| 16 | # You should have received a copy of the GNU General Public License
|
---|
| 17 | # along with this program; if not, write to the Free Software Foundation,
|
---|
| 18 | # Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
|
---|
| 19 |
|
---|
| 20 | # Prevent date giving response in another language.
|
---|
| 21 | LANG=C
|
---|
| 22 | export LANG
|
---|
| 23 | LC_ALL=C
|
---|
| 24 | export LC_ALL
|
---|
| 25 | LC_TIME=C
|
---|
| 26 | export LC_TIME
|
---|
| 27 |
|
---|
| 28 | # Get the extended ls output of the file or directory.
|
---|
| 29 | # On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
|
---|
| 30 | if ls -L /dev/null 1>/dev/null 2>&1; then
|
---|
| 31 | set - x`ls -L -l -d $1`
|
---|
| 32 | else
|
---|
| 33 | set - x`ls -l -d $1`
|
---|
| 34 | fi
|
---|
| 35 | # The month is at least the fourth argument
|
---|
| 36 | # (3 shifts here, the next inside the loop).
|
---|
| 37 | shift
|
---|
[3126] | 38 | # OS/2 doesn't necessarily have group/user columns, so we skip two shifts
|
---|
| 39 | if test -z "$OS2_SHELL"; then
|
---|
| 40 | shift
|
---|
| 41 | shift
|
---|
| 42 | fi
|
---|
[3124] | 43 |
|
---|
| 44 | # Find the month. Next argument is day, followed by the year or time.
|
---|
| 45 | month=
|
---|
| 46 | until test $month
|
---|
| 47 | do
|
---|
| 48 | shift
|
---|
| 49 | case $1 in
|
---|
| 50 | Jan) month=January; nummonth=1;;
|
---|
| 51 | Feb) month=February; nummonth=2;;
|
---|
| 52 | Mar) month=March; nummonth=3;;
|
---|
| 53 | Apr) month=April; nummonth=4;;
|
---|
| 54 | May) month=May; nummonth=5;;
|
---|
| 55 | Jun) month=June; nummonth=6;;
|
---|
| 56 | Jul) month=July; nummonth=7;;
|
---|
| 57 | Aug) month=August; nummonth=8;;
|
---|
| 58 | Sep) month=September; nummonth=9;;
|
---|
| 59 | Oct) month=October; nummonth=10;;
|
---|
| 60 | Nov) month=November; nummonth=11;;
|
---|
| 61 | Dec) month=December; nummonth=12;;
|
---|
| 62 | esac
|
---|
| 63 | done
|
---|
| 64 |
|
---|
| 65 | day=$2
|
---|
| 66 |
|
---|
| 67 | # Here we have to deal with the problem that the ls output gives either
|
---|
| 68 | # the time of day or the year.
|
---|
| 69 | case $3 in
|
---|
| 70 | *:*) set `date`; eval year=\$$#
|
---|
| 71 | case $2 in
|
---|
| 72 | Jan) nummonthtod=1;;
|
---|
| 73 | Feb) nummonthtod=2;;
|
---|
| 74 | Mar) nummonthtod=3;;
|
---|
| 75 | Apr) nummonthtod=4;;
|
---|
| 76 | May) nummonthtod=5;;
|
---|
| 77 | Jun) nummonthtod=6;;
|
---|
| 78 | Jul) nummonthtod=7;;
|
---|
| 79 | Aug) nummonthtod=8;;
|
---|
| 80 | Sep) nummonthtod=9;;
|
---|
| 81 | Oct) nummonthtod=10;;
|
---|
| 82 | Nov) nummonthtod=11;;
|
---|
| 83 | Dec) nummonthtod=12;;
|
---|
| 84 | esac
|
---|
| 85 | # For the first six month of the year the time notation can also
|
---|
| 86 | # be used for files modified in the last year.
|
---|
| 87 | if (expr $nummonth \> $nummonthtod) > /dev/null;
|
---|
| 88 | then
|
---|
| 89 | year=`expr $year - 1`
|
---|
| 90 | fi;;
|
---|
| 91 | *) year=$3;;
|
---|
| 92 | esac
|
---|
| 93 |
|
---|
| 94 | # The result.
|
---|
| 95 | echo $day $month $year
|
---|