how can I select the last entry from ls -la

how can I select the last entry from ls -la

Post by gregg_har.. » Wed, 03 May 2000 04:00:00



How can I select the last entry from a sorted list.

find . -name '*nv*' -exec ls -al {}\;

from this output I would like to keep the last displayed file name, so
I can create my script that says do not delete these files.

I am trying to keep the most current log file, but the dates are all
different.  I can't use mtime due to this problem.

Any help.

Gregg Harris

Sent via Deja.com http://www.deja.com/
Before you buy.

 
 
 

how can I select the last entry from ls -la

Post by Michael Sternber » Wed, 03 May 2000 04:00:00



> How can I select the last entry from a sorted list.
> find . -name '*nv*' -exec ls -al {}\;

        sed -n '$p'

Regards,
--
Michael Sternberg                        | Uni-GH Paderborn
http://www.phys.uni-paderborn.de/~stern/ | FB6 Theoretische Physik
phone: +49-(0)5251-60-2329   fax: -3435  | 33098 Paderborn, Germany
"Who disturrrbs me at this time?"  << Zaphod Beeblebrox IV >>     <*>

 
 
 

how can I select the last entry from ls -la

Post by Ari K Makel » Wed, 03 May 2000 04:00:00



> How can I select the last entry from a sorted list.

> find . -name '*nv*' -exec ls -al {}\;

> from this output I would like to keep the last displayed file name, so
> I can create my script that says do not delete these files.

tail -n1

--

use strict;my $s='I am just a poor bear with a startling lack of brain.';my $t=

 
 
 

how can I select the last entry from ls -la

Post by Matthew Land » Wed, 03 May 2000 04:00:00



> How can I select the last entry from a sorted list.

> find . -name '*nv*' -exec ls -al {}\;

> from this output I would like to keep the last displayed file name, so
> I can create my script that says do not delete these files.

> I am trying to keep the most current log file, but the dates are all
> different.  I can't use mtime due to this problem.

> Any help.

> Gregg Harris

> Sent via Deja.com http://www.deja.com/
> Before you buy.

Piping this output to tail -n1 is a good method.

However, you are createing a LOT of overhead by ls -al on all matches
when you only want ls -al of one.  Time could DRASTICALLY be reduced by
cleaning this up a little.  One quick clean up (I am sure there could
be better) is:

find . -name '*nv*' -print |tail -n1 |xargs ls -al

 - Matt

--
_______________________________________________________________________

   << Comments, views, and opinions are mine alone, not IBM's. >>

 
 
 

how can I select the last entry from ls -la

Post by Ron DuFresn » Thu, 04 May 2000 04:00:00


Ouch, find is so muh more resource intensive and can really lagout the
cpu, ls -la is much cleaner and less intrusive.

Laterer,

Ron DuFresne

:>
:> How can I select the last entry from a sorted list.
:>
:> find . -name '*nv*' -exec ls -al {}\;
:>
:> from this output I would like to keep the last displayed file name, so
:> I can create my script that says do not delete these files.
:>
:> I am trying to keep the most current log file, but the dates are all
:> different.  I can't use mtime due to this problem.
:>
:> Any help.
:>
:> Gregg Harris
:>
:> Sent via Deja.com http://www.deja.com/
:> Before you buy.

: Piping this output to tail -n1 is a good method.

: However, you are createing a LOT of overhead by ls -al on all matches
: when you only want ls -al of one.  Time could DRASTICALLY be reduced by
: cleaning this up a little.  One quick clean up (I am sure there could
: be better) is:

: find . -name '*nv*' -print |tail -n1 |xargs ls -al

:  - Matt

: --
: _______________________________________________________________________

:    << Comments, views, and opinions are mine alone, not IBM's. >>

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Cutting the space budget really restores my faith in humanity.  It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation." -- Johnny Hart
        ***testing, only testing, and damn good at it too!***

OK, so you're a Ph.D.  Just don't touch anything.

 
 
 

how can I select the last entry from ls -la

Post by Ron DuFresn » Thu, 04 May 2000 04:00:00


Opps, nevermind my last reply, I was not reading the whole process.

Thanks,

Ron DuFresne

:>
:> How can I select the last entry from a sorted list.
:>
:> find . -name '*nv*' -exec ls -al {}\;
:>
:> from this output I would like to keep the last displayed file name, so
:> I can create my script that says do not delete these files.
:>
:> I am trying to keep the most current log file, but the dates are all
:> different.  I can't use mtime due to this problem.
:>
:> Any help.
:>
:> Gregg Harris
:>
:> Sent via Deja.com http://www.deja.com/
:> Before you buy.

: Piping this output to tail -n1 is a good method.

: However, you are createing a LOT of overhead by ls -al on all matches
: when you only want ls -al of one.  Time could DRASTICALLY be reduced by
: cleaning this up a little.  One quick clean up (I am sure there could
: be better) is:

: find . -name '*nv*' -print |tail -n1 |xargs ls -al

:  - Matt

: --
: _______________________________________________________________________

:    << Comments, views, and opinions are mine alone, not IBM's. >>

--
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"Cutting the space budget really restores my faith in humanity.  It
eliminates dreams, goals, and ideals and lets us get straight to the
business of hate, debauchery, and self-annihilation." -- Johnny Hart
        ***testing, only testing, and damn good at it too!***

OK, so you're a Ph.D.  Just don't touch anything.

 
 
 

1. select field n to last? select last field?

"ls -ls" shows:

  12 -rw-r--r--   1 mwang    other       6144 Mar 14 12:53 scott_tiger.dmp
   6 drwxr-xr-x   2 mwang    other       2560 Jun  4 18:45 Shell

I want to only keep the fields:

Mar 14 12:53 scott_tiger.dmp
Jun  4 18:45 Shell

without any changes. For example,

"Jun  4" should not become
"Jun 4".

How do I do this? How do I get the LAST field without counting
how many fields are there? Thanks.

2. Need help to establish ipsec tunnel to etdvpn.sabre.com

3. ps and ls -la don't show everything for root

4. CD-Writer Help

5. ls -la $1 | less

6. Running X server app accessed by multiple clients...

7. su tobias -c 'ls -la' does and does not work, why?

8. /etc/vga/libvga.config? what is it?

9. ordering in linux 'ls -la'

10. ls -la command does not show certain directories/files

11. ls -la takes time on / ....

12. ssh hangs with commands like 'ls -la', 'vi ...' etc.

13. /usr/bin/ls /usr/ucb/ls /usr/local/bin/ls