#!/bin/csh -f

if ( $#argv == 0 ) then
	echo usage:
	echo "`basename $0` file.tar|file.tar.gz ..."
	exit 1
endif

foreach file ( $* )
	switch ( $file )
	case *.tar:
		set options=tvf
		breaksw
	case *.tar.gz:
	case *.tgz:
		set options=ztvf
		breaksw
	default:
		echo "$file skipped. Is it really a tar file?"
		continue
	endsw

	tar $options $file \
	|egrep -e '[-dl][-r][-w][-xs][-r][-w][-xs][-r][-w][-xt]' \
	|sed -e 's:^.*/[a-zA-Z0-9][a-zA-Z0-9]*  *[0-9][0-9]* \(.................\).*$:\1:' \
		-e 's-Jan-01-' -e 's-Feb-02-' -e 's-Mar-03-' -e 's-Apr-04-' \
		-e 's-May-05-' -e 's-Jun-06-' -e 's-Jul-07-' -e 's-Aug-08-' \
		-e 's-Sep-09-' -e 's-Oct-10-' -e 's-Nov-11-' -e 's-Dec-12-' \
		-e 's/-/ /g' \
		-e 's-\(..\) \(..\) \(..\):\(..\) \(....\)-\5:\1:\2:\3:\4-' \
		-e 's-\(....\) \(..\) \(..\) \(..\):\(..\)-\1:\2:\3:\4:\5-' \
	|sort -t: +0nr +1nr +2nr +3nr +4nr \
	|head -1 \
	|sed -e 's-\(....\):\(..\):\(..\):\(..\):\(..\)-\1/\2/\3 \4:\5-'
end


ViewGit