mdate-sh revision 1
45e9809aff7304721fddb95654901b32195c9c7avboxsync# Get modification time of a file or directory and pretty-print it.
45e9809aff7304721fddb95654901b32195c9c7avboxsync# Copyright (C) 1995, 1996, 1997, 2003, 2004 Free Software Foundation, Inc.
45e9809aff7304721fddb95654901b32195c9c7avboxsync# written by Ulrich Drepper <drepper@gnu.ai.mit.edu>, June 1995
45e9809aff7304721fddb95654901b32195c9c7avboxsync# This program is free software; you can redistribute it and/or modify
45e9809aff7304721fddb95654901b32195c9c7avboxsync# it under the terms of the GNU General Public License as published by
45e9809aff7304721fddb95654901b32195c9c7avboxsync# the Free Software Foundation; either version 2, or (at your option)
45e9809aff7304721fddb95654901b32195c9c7avboxsync# any later version.
45e9809aff7304721fddb95654901b32195c9c7avboxsync# This program is distributed in the hope that it will be useful,
45e9809aff7304721fddb95654901b32195c9c7avboxsync# but WITHOUT ANY WARRANTY; without even the implied warranty of
45e9809aff7304721fddb95654901b32195c9c7avboxsync# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
45e9809aff7304721fddb95654901b32195c9c7avboxsync# GNU General Public License for more details.
45e9809aff7304721fddb95654901b32195c9c7avboxsync# You should have received a copy of the GNU General Public License
45e9809aff7304721fddb95654901b32195c9c7avboxsync# along with this program; if not, write to the Free Software Foundation,
45e9809aff7304721fddb95654901b32195c9c7avboxsync# Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
45e9809aff7304721fddb95654901b32195c9c7avboxsync# As a special exception to the GNU General Public License, if you
45e9809aff7304721fddb95654901b32195c9c7avboxsync# distribute this file as part of a program that contains a
45e9809aff7304721fddb95654901b32195c9c7avboxsync# configuration script generated by Autoconf, you may include it under
45e9809aff7304721fddb95654901b32195c9c7avboxsync# the same distribution terms that you use for the rest of that program.
45e9809aff7304721fddb95654901b32195c9c7avboxsync# This file is maintained in Automake, please report
45e9809aff7304721fddb95654901b32195c9c7avboxsync# bugs to <bug-automake@gnu.org> or send patches to
45e9809aff7304721fddb95654901b32195c9c7avboxsync# <automake-patches@gnu.org>.
45e9809aff7304721fddb95654901b32195c9c7avboxsync echo "$0: No file. Try \`$0 --help' for more information." 1>&2
45e9809aff7304721fddb95654901b32195c9c7avboxsync echo "mdate-sh $scriptversion"
45e9809aff7304721fddb95654901b32195c9c7avboxsync# Prevent date giving response in another language.
45e9809aff7304721fddb95654901b32195c9c7avboxsync# Find out how to get the extended ls output of a file or directory.
45e9809aff7304721fddb95654901b32195c9c7avboxsync# A `ls -l' line looks as follows on OS/2.
45e9809aff7304721fddb95654901b32195c9c7avboxsync# drwxrwx--- 0 Aug 11 2001 foo
45e9809aff7304721fddb95654901b32195c9c7avboxsync# This differs from Unix, which adds ownership information.
45e9809aff7304721fddb95654901b32195c9c7avboxsync# drwxrwx--- 2 root root 4096 Aug 11 2001 foo
45e9809aff7304721fddb95654901b32195c9c7avboxsync# To find the date, we split the line on spaces and iterate on words
45e9809aff7304721fddb95654901b32195c9c7avboxsync# until we find a month. This cannot work with files whose owner is a
45e9809aff7304721fddb95654901b32195c9c7avboxsync# user named `Jan', or `Feb', etc. However, it's unlikely that `/'
45e9809aff7304721fddb95654901b32195c9c7avboxsync# will be owned by a user whose name is a month. So we first look at
45e9809aff7304721fddb95654901b32195c9c7avboxsync# the extended ls output of the root directory to decide how many
45e9809aff7304721fddb95654901b32195c9c7avboxsync# words should be skipped to get the date.
45e9809aff7304721fddb95654901b32195c9c7avboxsync# On HPUX /bin/sh, "set" interprets "-rw-r--r--" as options, so the "x" below.
45e9809aff7304721fddb95654901b32195c9c7avboxsyncset x`ls -l -d /`
45e9809aff7304721fddb95654901b32195c9c7avboxsync# Find which argument is the month.
45e9809aff7304721fddb95654901b32195c9c7avboxsync # Add another shift to the command.
45e9809aff7304721fddb95654901b32195c9c7avboxsync command="$command shift;"
eval $command