# Extract a timestamp from a file or directory in the format
# needed by touch.
# Copyright (c) 1994-2012 by Hamilton Laboratories. All rights reserved.
proc timestmp( file )
local j, t, month
if ( $#file == 0 ) then
echo -2 timestmp: No file or directory specified.
@ status = 1
return
end
if ( $#file > 1 ) then
echo -2 timestmp: Only one file or directory should be specified.
@ status = 1
end
if ( ! -e $file ) then
echo -2 timestmp: ^"$file^" does not exist.
@ status = 2
return
end
set t = `ls -L! $file`:1-4:gS/:0/:/:gs/:/ /
@ month = 1
foreach j ( Jan Feb Mar Apr May Jun Jul Aug Sep Oct Nov Dec )
if ( j == t[ 0 ] ) break
@ month++
end
return $printf( "%02d%02d%02d%02d%02d%02d", ^
month, t[ 1 ], t[ 2 ], t[ 3 ], t[ 4 ], t[ 5 ] )
end
timestmp $argv
|