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