Article View: es.comp.os.linux.programacion
Article #18135Re: Dias de vida de un fichero
From: J.A. Gutierrez
Date: Tue, 28 Sep 1999 00:00
Date: Tue, 28 Sep 1999 00:00
43 lines
2110 bytes
2110 bytes
JotaRP <jotarp@iname.com> wrote:
: "Jaime Su�rez" wrote:
:>
:> �C�mo calculo mediante un script shell o perl los d�as que hace que fue creado
:> un fichero?
:>
: Una soluci�n quiz� un poco bestia (pero que funciona):
: Para "fichero"...
: touch /tmp/hoy; expr \( `find /tmp -name hoy -printf "%T@\n"` - `find .
: -name fichero -printf "%T@\n"` \) / 86400
funciona siempre y cuando find sea la version de GNU y exista
/tmp/hoy$$ pero no /tmp/loquesea/hoy$$
: ...saca los dias que han pasado desde la �ltima modificaci�n.
: Habr�a que hacer /tmp/hoy con nombre �nico ( /tmp/hoy$$ ).
Otra pega es que los dos find pueden perder bastante tiempo si
el /tmp esta poblado...
Otra solucion posible, ya que perl se menciona como alternativa:
#!/usr/local/bin/perl
($dev,$ino,$mode,$nlink,$uid,$gid,$rdev,$size,
$atime,$mtime,$ctime,$blksize,$blocks)=
stat("/etc/motd");
$secs = time();
$diff= ( $secs - $mtime ) / ( 60 * 60 * 24 );
print "$diff\n";
--
PGP and other useless info at \ Oh, show us the way
http://www.cps.unizar.es/~spd/ \ to the next whisky bar
finger://daphne.cps.unizar.es/spd \ Weill/Bretch
Lo que si que es cierto es que la felicidad no da el dinero...
Technical Details
Message-ID:
<7sqtom$a1$1@posta2.unizar.es>Path:
arc1-ca.pugleaf.net!unknown!not-for-mailReferences:
<slrn7usque.11t.jsuarez@localhost.localdomain> <37F0D8D1.ED00F3B3@iname.com>Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,af39932ff6eb6b5d
X-Google-Attributes: gidf86c8,public
From: "J.A. Gutierrez" <spd@daphne.cps.unizar.es>
Subject: Re: Dias de vida de un fichero
Date: 1999/09/28
Message-ID: <7sqtom$a1$1@posta2.unizar.es>
X-Deja-AN: 530368555
Content-Transfer-Encoding: 8bit
References: <slrn7usque.11t.jsuarez@localhost.localdomain> <37F0D8D1.ED00F3B3@iname.com>
Content-Type: text/plain; charset=ISO-8859-1
X-Complaints-To: usenet@news.unizar.es
X-Trace: posta2.unizar.es 938539606 321 155.210.152.20 (28 Sep 1999 17:26:46 GMT)
Organization: Rank
Mime-Version: 1.0
User-Agent: tin/pre-1.4-19990413 ("Endemoniada") (UNIX) (IRIX/6.2 (IP22))
NNTP-Posting-Date: 28 Sep 1999 17:26:46 GMT
Newsgroups: es.comp.os.linux.programacion