Re: [gentoo-user] Re: [OT] Finding old files

2010-11-20 Thread Peter Humphrey
On Saturday 20 November 2010 05:31:15 Grant Edwards wrote:
 On 2010-11-20, Peter Humphrey pe...@humphrey.ukfsn.org wrote:
  On Friday 19 November 2010 17:53:31 Grant Edwards wrote:
  
  What different behavior?
  
  As I said, from the command line ls shows the year for any file
  more than 12 months old, in place of the time. When executed from
  find it doesn't.
 
 I don't see any difference when I do it.

It turns out that the difference is in the 'c' switch to ls. With the 
switch I get this (grepping for a single file of the many):

$ find . -iname \*.jpg -exec ls '-cdhl' {} \; | grep DSC_1810.JPG
-r-xr-xr-x 1 prh prh 3.7M Aug 11 17:32 ./images/BOH-2009/DSC_1810.JPG

and without it I get this:

$ find . -iname \*.jpg -exec ls '-dhl' {} \; | grep DSC_1810.JPG
-r-xr-xr-x 1 prh prh 3.7M Oct 28  2009 ./images/BOH-2009/DSC_1810.JPG

Perhaps some process I ran on 11 August this year touched the file 
without modifying it. Anyway, it seems there isn't a problem (except in 
my website[1] management techniques, perhaps). Thanks anyway.

$ equery l coreutils
 * Searching for coreutils ...
[IP-] [  ] sys-apps/coreutils-8.7:0

[1] I don't suppose anyone's interested, but just in case, the site is 
at http://tideswellmvc.co.uk/; It's been my baby for about 18 months.

-- 
Rgds
Peter.  Linux Counter 5290, 1994-04-23.



[gentoo-user] Re: [OT] Finding old files

2010-11-19 Thread Grant Edwards
On 2010-11-19, Peter Humphrey pe...@humphrey.ukfsn.org wrote:
 Hello list,

 Just to expose my ignorance again, would someone lift my blinkers 
 please? I'm recovering from an infection and my brain is stuck.

 It's time to start pruning old stuff from the website I run, which has 
 2200 files in 200 directories.

 I'm trying to find old images like this:
 find . -iname \*.jpg -exec ls '-cdl' {} \; | cut -d \  -f 5-10

It's obvious how that command finds old images.  Can you explain what
it's supposed to do?

 Is there a simple way to do this? Ideally I'd like a chronologically 
 ordered list of the files.

Do you want a chronologically ordered list, or do you want to find
files older than a certain age?

If the former, try this:

  find . -iname '*.jpg' | xargs ls -lt

If the latter, read the 'find' man page and look for the -mtime test.

-- 
Grant Edwards   grant.b.edwardsYow! My nose feels like a
  at   bad Ronald Reagan movie ...
  gmail.com




Re: [gentoo-user] Re: [OT] Finding old files

2010-11-19 Thread Peter Humphrey
On Friday 19 November 2010 16:40:37 Grant Edwards wrote:
 On 2010-11-19, Peter Humphrey pe...@humphrey.ukfsn.org wrote:
  Hello list,
  
  Just to expose my ignorance again, would someone lift my blinkers
  please? I'm recovering from an infection and my brain is stuck.
  
  It's time to start pruning old stuff from the website I run, which
  has 2200 files in 200 directories.
  
  I'm trying to find old images like this:
  find . -iname \*.jpg -exec ls '-cdl' {} \; | cut -d \  -f 5-10
 
 It's obvious how that command finds old images.  Can you explain what
 it's supposed to do?

The cut command simply strips off the permissions, owner, group and file 
size.

Never mind, anyway. I've done it by using separate steps instead of 
trying to combine them. I'm still puzzled though at the different 
behaviour of ls between command-line and execution by find.

-- 
Rgds
Peter.  Linux Counter 5290, 1994-04-23.



[gentoo-user] Re: [OT] Finding old files

2010-11-19 Thread Grant Edwards
On 2010-11-19, Alan McKinnon alan.mckin...@gmail.com wrote:
 Apparently, though unproven, at 19:18 on Friday 19 November 2010, Peter 
 Humphrey did opine thusly:

 On Friday 19 November 2010 16:40:37 Grant Edwards wrote:
  On 2010-11-19, Peter Humphrey pe...@humphrey.ukfsn.org wrote:
   Hello list,
   
   Just to expose my ignorance again, would someone lift my blinkers
   please? I'm recovering from an infection and my brain is stuck.
   
   It's time to start pruning old stuff from the website I run, which
   has 2200 files in 200 directories.
   
   I'm trying to find old images like this:
   find . -iname \*.jpg -exec ls '-cdl' {} \; | cut -d \  -f 5-10
  
  It's obvious how that command finds old images.  Can you explain what
  it's supposed to do?
 
 The cut command simply strips off the permissions, owner, group and file
 size.
 
 Never mind, anyway. I've done it by using separate steps instead of
 trying to combine them. I'm still puzzled though at the different
 behaviour of ls between command-line and execution by find.

 ls as you are using it is an option to find (not an app or a shell
 builtin).  So you need to do

No, in his case ls it's an app that's executed by the find command by
as part of the handling of the find command's -exec clause.

-- 
Grant Edwards   grant.b.edwardsYow! LOOK!!  Sullen
  at   American teens wearing
  gmail.comMADRAS shorts and Flock of
   Seagulls HAIRCUTS!




Re: [gentoo-user] Re: [OT] Finding old files

2010-11-19 Thread Alan McKinnon
Apparently, though unproven, at 19:18 on Friday 19 November 2010, Peter 
Humphrey did opine thusly:

 On Friday 19 November 2010 16:40:37 Grant Edwards wrote:
  On 2010-11-19, Peter Humphrey pe...@humphrey.ukfsn.org wrote:
   Hello list,
   
   Just to expose my ignorance again, would someone lift my blinkers
   please? I'm recovering from an infection and my brain is stuck.
   
   It's time to start pruning old stuff from the website I run, which
   has 2200 files in 200 directories.
   
   I'm trying to find old images like this:
   find . -iname \*.jpg -exec ls '-cdl' {} \; | cut -d \  -f 5-10
  
  It's obvious how that command finds old images.  Can you explain what
  it's supposed to do?
 
 The cut command simply strips off the permissions, owner, group and file
 size.
 
 Never mind, anyway. I've done it by using separate steps instead of
 trying to combine them. I'm still puzzled though at the different
 behaviour of ls between command-line and execution by find.


ls as you are using it is an option to find (not an app or a shell builtin). 
So you need to do

find  -ls


-- 
alan dot mckinnon at gmail dot com



[gentoo-user] Re: [OT] Finding old files

2010-11-19 Thread Grant Edwards
On 2010-11-19, Peter Humphrey pe...@humphrey.ukfsn.org wrote:
 On Friday 19 November 2010 16:40:37 Grant Edwards wrote:
 On 2010-11-19, Peter Humphrey pe...@humphrey.ukfsn.org wrote:

 Just to expose my ignorance again, would someone lift my blinkers
 please? I'm recovering from an infection and my brain is stuck.
 
 It's time to start pruning old stuff from the website I run, which
 has 2200 files in 200 directories.
 
 I'm trying to find old images like this:
 find . -iname \*.jpg -exec ls '-cdl' {} \; | cut -d \  -f 5-10
 
 It's not obvious how that command finds old images.  Can you explain
 what it's supposed to do?

 The cut command simply strips off the permissions, owner, group and
 file size.

OK, but I still don't see how that finds old image files, but
whatever.

 Never mind, anyway. I've done it by using separate steps instead of 
 trying to combine them. I'm still puzzled though at the different 
 behaviour of ls between command-line and execution by find.

 find . -iname \*.jpg -exec ls '-cdl --time-style=full-iso' {} \; |\
 cut -d \  -f 5-10

What different behavior?

That ls command doesn't work from the command line either:

  $ ls '-cdl --time-style=full-iso' foo
  ls: invalid option -- ' '
  Try ls --help' for more information.

The quotes cause both option specifiers '-cdl' and
'--time-style=full-iso' to be passed to 'ls' as single string with
whitespace in the middle of it.  That's not how options are passed to
Unix command line utilities.

I think what you intended was

  $ ls -cdl --time-style=full-iso foo
  -rw-r--r-- 1 grante users 96 2010-11-19 11:44:45.0 -0600 foo

IOW:

  $ find -iname '*.jpg' -exec ls -cdl --time-style=full-iso {} \; | cut -d ' ' 
-f 5-10
  40369 2010-03-22 13:59:28.0 -0500 
./rfc2217-xon-xoff/right_cncbaron_small.jpg
  110641 2010-03-23 10:21:16.0 -0500 
./rfc2217-xon-xoff/DMFreeWire-1-Port 300dpi
  22330 2010-03-22 14:01:26.0 -0500 
./rfc2217-xon-xoff/clip_image002_0006.jpg
  [...]

Note that your cut doesn't work right for filenames that contain
spaces...
  
-- 
Grant Edwards   grant.b.edwardsYow! Maybe I should have
  at   asked for my Neutron Bomb
  gmail.comin PAISLEY --




Re: [gentoo-user] Re: [OT] Finding old files

2010-11-19 Thread Stroller

On 19/11/2010, at 5:53pm, Grant Edwards wrote:
 ...
 OK, but I still don't see how that finds old image files, but
 whatever.

I assume he's finding *all* image files, then searching himself for old ones. 
This seems obvious to me, but maybe I'm missing something?

Stroller.




[gentoo-user] Re: [OT] Finding old files

2010-11-19 Thread Grant Edwards
On 2010-11-19, Stroller strol...@stellar.eclipse.co.uk wrote:

 On 19/11/2010, at 5:53pm, Grant Edwards wrote:
 ...
 OK, but I still don't see how that finds old image files, but
 whatever.

 I assume he's finding *all* image files, then searching himself for
 old ones. This seems obvious to me, but maybe I'm missing something?

You're probably right.  I had it stuck in my head that he though the
command was finding old files.

-- 
Grant Edwards   grant.b.edwardsYow! My pants just went to
  at   high school in the Carlsbad
  gmail.comCaverns!!!




Re: [gentoo-user] Re: [OT] Finding old files

2010-11-19 Thread Peter Humphrey
On Friday 19 November 2010 17:53:31 Grant Edwards wrote:
 On 2010-11-19, Peter Humphrey pe...@humphrey.ukfsn.org wrote:
 
 What different behavior?

As I said, from the command line ls shows the year for any file more than 
12 months old, in place of the time. When executed from find it doesn't.
 
 That ls command doesn't work from the command line either:
...
 I think what you intended was
 
   $ ls -cdl --time-style=full-iso foo

You're right. I pasted the wrong command in - sorry.

 Note that your cut doesn't work right for filenames that contain
 spaces...

I don't allow such files on my systems. Even if I did, in this case I'd 
spot the error when it happened (I hope).

Thanks anyway.

-- 
Rgds
Peter.  Linux Counter 5290, 1994-04-23.



[gentoo-user] Re: [OT] Finding old files

2010-11-19 Thread Grant Edwards
On 2010-11-20, Peter Humphrey pe...@humphrey.ukfsn.org wrote:
 On Friday 19 November 2010 17:53:31 Grant Edwards wrote:
 On 2010-11-19, Peter Humphrey pe...@humphrey.ukfsn.org wrote:
  
 What different behavior?

 As I said, from the command line ls shows the year for any file more than 
 12 months old, in place of the time. When executed from find it doesn't.

I don't see any difference when I do it.  Can you post a shell script
that shows the two different behaviors?

 That ls command doesn't work from the command line either:
 ...
 I think what you intended was
 
   $ ls -cdl --time-style=full-iso foo

 You're right. I pasted the wrong command in - sorry.

 Note that your cut doesn't work right for filenames that contain
 spaces...

 I don't allow such files on my systems. Even if I did, in this case I'd 
 spot the error when it happened (I hope).

-- 
Grant