Revision 16,
1.2 KB
checked in by marcus, 15 years ago
(diff) |
r1 | svn | 2007-12-13 11:10:29 +0100 (Do, 13 Dez 2007) | 2 lines
Initial import
|
-
Property svn:executable set to
*
|
Line | |
---|
1 | #! /bin/csh |
---|
2 | # |
---|
3 | # file fileage.csh |
---|
4 | # =========== |
---|
5 | # |
---|
6 | # version 4, 28-Dec-2006 |
---|
7 | # |
---|
8 | # Returns age of file in sec |
---|
9 | # K. Stammler, 8-May-2000 |
---|
10 | |
---|
11 | if ("$1" == "") then |
---|
12 | echo "Usage: $0 <file>" |
---|
13 | exit |
---|
14 | endif |
---|
15 | |
---|
16 | # get parameters |
---|
17 | set fname=$1 |
---|
18 | |
---|
19 | #set echo |
---|
20 | |
---|
21 | if ("`uname`" == "Linux") then |
---|
22 | |
---|
23 | if (! -e $fname) exit |
---|
24 | |
---|
25 | set ftime=`ls -l --time-style=+%d-%h-%y_%T $fname | awk '{print $6}'` |
---|
26 | if ("$ftime" == "") then |
---|
27 | set res=`ls -l --full-time $fname` |
---|
28 | if ($#res < 7) exit |
---|
29 | set tm=`echo $res[7] | sed 's/:/ /g'` |
---|
30 | set res=`echo $res[6] | sed 's/-/ /g'` |
---|
31 | set secs=`echo $tm[3] | sed 's/\./ /'` |
---|
32 | set secs=$secs[1] |
---|
33 | set ftime=$res[3],$res[2],$res[1],$tm[1],$tm[2],$secs |
---|
34 | set ctime=`date +%d,%m,%y,%H,%M,%S` |
---|
35 | set tdiff=`$SH_UTIL/timename time_intdiff $ctime $ftime` |
---|
36 | echo $tdiff |
---|
37 | else |
---|
38 | $SH_UTIL/timename time_intdiff `date +%d-%h-%y_%T` $ftime |
---|
39 | endif |
---|
40 | |
---|
41 | else |
---|
42 | |
---|
43 | if (! -e $fname) then |
---|
44 | echo "-1 file $fname does not exist." |
---|
45 | exit |
---|
46 | endif |
---|
47 | |
---|
48 | set res=`ls -l $fname` |
---|
49 | if ($#res < 8) then |
---|
50 | echo "-1 Syntax error in output of ls" |
---|
51 | exit |
---|
52 | endif |
---|
53 | |
---|
54 | set month=$res[6] |
---|
55 | set day=$res[7] |
---|
56 | set tm=$res[8] |
---|
57 | set year=`date +%y` |
---|
58 | |
---|
59 | $SH_UTIL/timename time_intdiff `date +%d-%h-%y_%T` $day-$month-${year}_$tm |
---|
60 | |
---|
61 | endif |
---|
62 | |
---|
Note: See
TracBrowser
for help on using the repository browser.