Gentoo Archives: gentoo-user

From: Grant Edwards <grant.b.edwards@×××××.com>
To: gentoo-user@l.g.o
Subject: [gentoo-user] Re: [OT] Finding old files
Date: Fri, 19 Nov 2010 18:08:09
Message-Id: ic6dir$dmi$1@dough.gmane.org
In Reply to: Re: [gentoo-user] Re: [OT] Finding old files by Peter Humphrey
1 On 2010-11-19, Peter Humphrey <peter@××××××××××××××.org> wrote:
2 > On Friday 19 November 2010 16:40:37 Grant Edwards wrote:
3 >> On 2010-11-19, Peter Humphrey <peter@××××××××××××××.org> wrote:
4
5 >>> Just to expose my ignorance again, would someone lift my blinkers
6 >>> please? I'm recovering from an infection and my brain is stuck.
7 >>>
8 >>> It's time to start pruning old stuff from the website I run, which
9 >>> has 2200 files in 200 directories.
10 >>>
11 >>> I'm trying to find old images like this:
12 >>> find . -iname \*.jpg -exec ls '-cdl' {} \; | cut -d \ -f 5-10
13 >>
14 >> It's not obvious how that command finds old images. Can you explain
15 >> what it's supposed to do?
16 >
17 > The cut command simply strips off the permissions, owner, group and
18 > file size.
19
20 OK, but I still don't see how that "finds old image files", but
21 whatever.
22
23 > Never mind, anyway. I've done it by using separate steps instead of
24 > trying to combine them. I'm still puzzled though at the different
25 > behaviour of ls between command-line and execution by find.
26
27 >>> find . -iname \*.jpg -exec ls '-cdl "--time-style=full-iso"' {} \; |\
28 >>> cut -d \ -f 5-10
29
30 What different behavior?
31
32 That ls command doesn't work from the command line either:
33
34 $ ls '-cdl "--time-style=full-iso"' foo
35 ls: invalid option -- ' '
36 Try ls --help' for more information.
37
38 The quotes cause both option specifiers '-cdl' and
39 '--time-style=full-iso' to be passed to 'ls' as single string with
40 whitespace in the middle of it. That's not how options are passed to
41 Unix command line utilities.
42
43 I think what you intended was
44
45 $ ls -cdl --time-style=full-iso foo
46 -rw-r--r-- 1 grante users 96 2010-11-19 11:44:45.000000000 -0600 foo
47
48 IOW:
49
50 $ find -iname '*.jpg' -exec ls -cdl --time-style=full-iso {} \; | cut -d ' ' -f 5-10
51 40369 2010-03-22 13:59:28.000000000 -0500 ./rfc2217-xon-xoff/right_cncbaron_small.jpg
52 110641 2010-03-23 10:21:16.000000000 -0500 ./rfc2217-xon-xoff/DMFreeWire-1-Port 300dpi
53 22330 2010-03-22 14:01:26.000000000 -0500 ./rfc2217-xon-xoff/clip_image002_0006.jpg
54 [...]
55
56 Note that your "cut" doesn't work right for filenames that contain
57 spaces...
58
59 --
60 Grant Edwards grant.b.edwards Yow! Maybe I should have
61 at asked for my Neutron Bomb
62 gmail.com in PAISLEY --

Replies

Subject Author
Re: [gentoo-user] Re: [OT] Finding old files Stroller <stroller@××××××××××××××××××.uk>
Re: [gentoo-user] Re: [OT] Finding old files Peter Humphrey <peter@××××××××××××××.org>