PHWinfo banniere

Titres
PORTAIL ANNUAIRE ARTICLES COMPARATEUR HÉBERGEURS DEVIS FORUMS RÉDUCTEUR D'URL
Précédent   PHWinfo > Forums Hébergement > Forum Serveur - Sécurité et techniques > comp.unix.shell > Script to sort file by access time
S'inscrire FAQ Membres Recherche Messages du jour Marquer les forums comme lus
comp.unix.shell Using and programming the Unix shell.

Script to sort file by access time

Réponse
 
LinkBack Outils de la discussion
Vieux 09/11/2006, 08h51   #1
yannick.dhennin@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Script to sort file by access time

Hi,

I have a problem to develop a script that sort files by access time.

I've tried the command ls -ltu or stat -c "%x %n" *, but the problem is
that when i'm launching the script, the date of last access is update
with the time of the script.

Do you have an idea for this problem ?

Thanks a lot.

whizzzz

  Réponse avec citation
Vieux 09/11/2006, 09h13   #2
Michael Tosch
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to sort file by access time

yannick.dhennin@gmail.com wrote:
> Hi,
>
> I have a problem to develop a script that sort files by access time.
>
> I've tried the command ls -ltu or stat -c "%x %n" *, but the problem is
> that when i'm launching the script, the date of last access is update
> with the time of the script.
>
> Do you have an idea for this problem ?
>


??
The atime does not change by an ls or stat command.
ls -1tu
should work ok.

--
Michael Tosch @ hp : com
  Réponse avec citation
Vieux 09/11/2006, 09h46   #3
Stephane CHAZELAS
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to sort file by access time

2006-11-09, 10:13(+01), Michael Tosch:
> yannick.dhennin@gmail.com wrote:
>> Hi,
>>
>> I have a problem to develop a script that sort files by access time.
>>
>> I've tried the command ls -ltu or stat -c "%x %n" *, but the problem is
>> that when i'm launching the script, the date of last access is update
>> with the time of the script.
>>
>> Do you have an idea for this problem ?
>>

>
> ??
> The atime does not change by an ls or stat command.
> ls -1tu
> should work ok.

[...]

Maybe the OP did a

ls -ltu *

in which case the atime of the directories where updated as
their content was read.

ls -ltu

or

ls -ltud -- *

should not have the problem.

--
Stéphane
  Réponse avec citation
Vieux 09/11/2006, 15h34   #4
yannick.dhennin@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to sort file by access time

Hi,

thanks for your answers.

the problem is when I'm doing ls -ltu or stat command the access time
is modified at the time the command is done.

Is it possible to have access to tha access time information of a file
without modify it ?

Thanks a lot,

Yannick.

Stephane CHAZELAS a écrit :

> 2006-11-09, 10:13(+01), Michael Tosch:
> > yannick.dhennin@gmail.com wrote:
> >> Hi,
> >>
> >> I have a problem to develop a script that sort files by access time.
> >>
> >> I've tried the command ls -ltu or stat -c "%x %n" *, but the problem is
> >> that when i'm launching the script, the date of last access is update
> >> with the time of the script.
> >>
> >> Do you have an idea for this problem ?
> >>

> >
> > ??
> > The atime does not change by an ls or stat command.
> > ls -1tu
> > should work ok.

> [...]
>
> Maybe the OP did a
>
> ls -ltu *
>
> in which case the atime of the directories where updated as
> their content was read.
>
> ls -ltu
>
> or
>
> ls -ltud -- *
>
> should not have the problem.
>
> --
> Stéphane


  Réponse avec citation
Vieux 09/11/2006, 15h47   #5
Janis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to sort file by access time

yannick.dhennin@gmail.com wrote:
> Hi,
>
> thanks for your answers.
>
> the problem is when I'm doing ls -ltu or stat command the access time
> is modified at the time the command is done.
>
> Is it possible to have access to tha access time information of a file
> without modify it ?


As has been said, if you compare ordinary files:
"The atime does not change by an ls or stat command."

If in your case that's different you have to provide more information
about your environment, and show what you've exactly done and what
exactly the results have been.

And, BTW, don't top-post.

Janis


>
> Thanks a lot,
>
> Yannick.
>
> Stephane CHAZELAS a écrit :
>
> > 2006-11-09, 10:13(+01), Michael Tosch:
> > > yannick.dhennin@gmail.com wrote:
> > >> Hi,
> > >>
> > >> I have a problem to develop a script that sort files by access time.
> > >>
> > >> I've tried the command ls -ltu or stat -c "%x %n" *, but the problemis
> > >> that when i'm launching the script, the date of last access is update
> > >> with the time of the script.
> > >>
> > >> Do you have an idea for this problem ?
> > >>
> > >
> > > ??
> > > The atime does not change by an ls or stat command.
> > > ls -1tu
> > > should work ok.

> > [...]
> >
> > Maybe the OP did a
> >
> > ls -ltu *
> >
> > in which case the atime of the directories where updated as
> > their content was read.
> >
> > ls -ltu
> >
> > or
> >
> > ls -ltud -- *
> >
> > should not have the problem.
> >
> > --
> > Stéphane


  Réponse avec citation
Vieux 10/11/2006, 01h20   #6
Barry Margolin
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to sort file by access time

In article <1163087221.491720.98960@m73g2000cwd.googlegroups. com>,
"Janis" <janis_papanagnou@hotmail.com> wrote:

> yannick.dhennin@gmail.com wrote:
> > Hi,
> >
> > thanks for your answers.
> >
> > the problem is when I'm doing ls -ltu or stat command the access time
> > is modified at the time the command is done.
> >
> > Is it possible to have access to tha access time information of a file
> > without modify it ?

>
> As has been said, if you compare ordinary files:
> "The atime does not change by an ls or stat command."
>
> If in your case that's different you have to provide more information
> about your environment, and show what you've exactly done and what
> exactly the results have been.


When I saw his first post, my thought was that one of the files he's
listing is the script itself. Executing the script will indeed update
the atime of the script -- the shell has to read the script to execute
it.

--
Barry Margolin, barmar@alum.mit.edu
Arlington, MA
*** PLEASE post questions in newsgroups, not directly to me ***
*** PLEASE don't copy me on replies, I'll read them in the group ***
  Réponse avec citation
Vieux 10/11/2006, 10h33   #7
yannick.dhennin@gmail.com
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to sort file by access time


Barry Margolin a écrit :

> In article <1163087221.491720.98960@m73g2000cwd.googlegroups. com>,
> "Janis" <janis_papanagnou@hotmail.com> wrote:
>
> > yannick.dhennin@gmail.com wrote:
> > > Hi,
> > >
> > > thanks for your answers.
> > >
> > > the problem is when I'm doing ls -ltu or stat command the access time
> > > is modified at the time the command is done.
> > >
> > > Is it possible to have access to tha access time information of a file
> > > without modify it ?

> >
> > As has been said, if you compare ordinary files:
> > "The atime does not change by an ls or stat command."
> >
> > If in your case that's different you have to provide more information
> > about your environment, and show what you've exactly done and what
> > exactly the results have been.

>
> When I saw his first post, my thought was that one of the files he's
> listing is the script itself. Executing the script will indeed update
> the atime of the script -- the shell has to read the script to execute
> it.
>
> --
> Barry Margolin, barmar@alum.mit.edu
> Arlington, MA
> *** PLEASE post questions in newsgroups, not directly to me ***
> *** PLEASE don't copy me on replies, I'll read them in the group ***


Hi,

The script is done for cygwin environement. It can explain why the
access-time is update.

Yannick.

  Réponse avec citation
Vieux 10/11/2006, 14h09   #8
Janis
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to sort file by access time

yannick.dhennin@gmail.com wrote:
> Barry Margolin a écrit :
> > In article <1163087221.491720.98960@m73g2000cwd.googlegroups. com>,
> > "Janis" <janis_papanagnou@hotmail.com> wrote:
> > > yannick.dhennin@gmail.com wrote:
> > > > Hi,
> > > >
> > > > thanks for your answers.
> > > >
> > > > the problem is when I'm doing ls -ltu or stat command the access time
> > > > is modified at the time the command is done.
> > > >
> > > > Is it possible to have access to tha access time information of a file
> > > > without modify it ?
> > >
> > > As has been said, if you compare ordinary files:
> > > "The atime does not change by an ls or stat command."
> > >
> > > If in your case that's different you have to provide more information
> > > about your environment, and show what you've exactly done and what
> > > exactly the results have been.

> >
> > When I saw his first post, my thought was that one of the files he's
> > listing is the script itself. Executing the script will indeed update
> > the atime of the script -- the shell has to read the script to execute
> > it.
> >

>
> Hi,
>
> The script is done for cygwin environement. It can explain why the
> access-time is update.


No, that doesn't, per se, explain anything.
'ls -ltu' works for me with bash on Cygwin as expected.

To repeat what I said: "[...] and show what you've exactly done and
what exactly the results have been."

Janis

>
> Yannick.


  Réponse avec citation
Vieux 11/11/2006, 04h45   #9
Bill Marcum
Aucun Avatar
 
Messages: n/a
Hébergeur:
Par défaut Re: Script to sort file by access time

On 10 Nov 2006 06:09:04 -0800, Janis
<janis_papanagnou@hotmail.com> wrote:
> yannick.dhennin@gmail.com wrote:
>>
>> Hi,
>>
>> The script is done for cygwin environement. It can explain why the
>> access-time is update.

>
> No, that doesn't, per se, explain anything.
> 'ls -ltu' works for me with bash on Cygwin as expected.
>
> To repeat what I said: "[...] and show what you've exactly done and
> what exactly the results have been."
>

It might matter which version of Windows and which filesystem (FAT or
NTFS) is being used.


--
A university is what a college becomes when the faculty loses interest
in students.
-- John Ciardi
  Réponse avec citation
Réponse


Outils de la discussion

Règles de messages
Vous ne pouvez pas créer de nouvelles discussions
Vous ne pouvez pas envoyer des réponses
Vous ne pouvez pas envoyer des pièces jointes
Vous ne pouvez pas modifier vos messages

Les balises BB sont activées : oui
Les smileys sont activés : oui
La balise [IMG] est activée : oui
Le code HTML peut être employé : non
Trackbacks are oui
Pingbacks are oui
Refbacks are oui


Fuseau horaire GMT +1. Il est actuellement 22h31.


Édité par : vBulletin® version 3.7.3
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.2.0 RC5 Tous droits réservés.
Version française #16 par l'association vBulletin francophone
PHWinfo est un site Éducation Sans Frontières ©2000-2008
Ad Management by RedTyger
©Tous droits réservés par les parties respectives
Page generated in 0,20177 seconds with 17 queries