Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #69623
| Path | csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!goblin3!goblin1!goblin2!goblin.stu.neva.ru!newsfeed1.swip.net!uio.no!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail |
|---|---|
| Return-Path | <bouncingcats@gmail.com> |
| X-Original-To | python-list@python.org |
| Delivered-To | python-list@mail.python.org |
| X-Spam-Status | OK 0.002 |
| X-Spam-Evidence | '*H*': 1.00; '*S*': 0.00; 'subject:Windows': 0.02; 'syntax': 0.04; 'motivated': 0.05; 'widely': 0.05; '*not*': 0.07; 'abuse': 0.07; 'expressions': 0.07; 'processing.': 0.07; 'rush': 0.09; 'spaces': 0.09; 'tests,': 0.09; 'things,': 0.09; 'used.': 0.09; 'itself.': 0.14; '*before*': 0.16; '*expression*': 0.16; '-o,': 0.16; 'command,': 0.16; 'command-line': 0.16; 'example)': 0.16; 'expecting': 0.16; 'expression.': 0.16; 'intended.': 0.16; 'rarely': 0.16; 'simplest': 0.16; 'stuff.': 0.16; 'subject:Unicode': 0.16; 'tasks,': 0.16; 'unix-style': 0.16; 'wrote:': 0.18; '(not': 0.18; 'all,': 0.19; 'unlike': 0.19; 'command': 0.22; 'shell': 0.22; 'to:name:python-list@python.org': 0.22; 'commands,': 0.24; 'options': 0.25; 'order.': 0.26; 'task': 0.26; 'pass': 0.26; '(for': 0.26; 'header:In-Reply-To:1': 0.27; 'chris': 0.29; 'feature': 0.29; 'wonder': 0.29; 'characters': 0.30; 'compared': 0.30; 'message-id:@mail.gmail.com': 0.30; '"do': 0.31; 'invoke': 0.31; 'so-called': 0.31; 'anyone': 0.31; 'at:': 0.34; 'knowledge': 0.35; "can't": 0.35; 'info': 0.35; 'display': 0.35; 'except': 0.35; 'tool': 0.35; 'something': 0.35; 'done.': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'version': 0.36; 'url:org': 0.36; 'effort': 0.37; 'two': 0.37; 'list': 0.37; 'tools,': 0.38; 'handle': 0.38; 'to:addr:python- list': 0.38; 'files': 0.38; 'rather': 0.38; 'that,': 0.38; 'little': 0.38; 'extremely': 0.39; 'to:addr:python.org': 0.39; 'even': 0.60; 'read': 0.60; 'eventually': 0.60; 'expression': 0.60; 'truly': 0.60; 'most': 0.60; 'helps': 0.61; 'interested,': 0.61; 'back': 0.62; 'offer': 0.62; 'name': 0.63; 'such': 0.63; 'more': 0.64; 'different': 0.65; 'here': 0.66; 'capable': 0.67; 'results': 0.69; 'fact,': 0.69; 'carefully': 0.74; 'hoping': 0.75; 'actions,': 0.84; 'confusing': 0.84; 'confusion.': 0.84; 'describes': 0.84; 'crucial': 0.91; 'mistake': 0.91; 'poorly': 0.93 |
| DKIM-Signature | v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :content-type; bh=aiwU+jvtlq++0X0G/SURcBeWgl33ul9iq/nv0qcAM9s=; b=m2lMNoiTQNHfIt9RS1YO8xlMR36XF8VgqAj/+ShyMK8zGl2tzwucuhyNuSl23NVIzC j+QXYxcoj+3Kh/pyyoE2uv1n4wlk/qCl/Dl8n5LPdYXwzogIAaVzPrv5tqfGyb6ucrbz wWcxXgCBnhSuvySJlUt1IpnHEnmjkud6f4SmsdH7ROdCtNM3bGYdJN4lBGcLBVjPTx92 /I92BepNGMOkPaZ3MD75+9WBB7GPlR5pihRlQuT8N5lai03CJeGfDm/G1edq164PnsET Hv8iMfDYszDlkQjxYyr5aeptLB/cutMBVpwPteUJFOFcWgdfSf9QDMr06uKFw3Bp5U0s mvFg== |
| MIME-Version | 1.0 |
| X-Received | by 10.220.133.80 with SMTP id e16mr5327618vct.13.1396570557503; Thu, 03 Apr 2014 17:15:57 -0700 (PDT) |
| In-Reply-To | <CAPTjJmpQhneBQF2070AS=dfFFCU6E5_O8OFiM2rVf40duLCB-A@mail.gmail.com> |
| References | <f3b4238a-6bf4-478e-9326-1ba239d5237f@googlegroups.com> <533cc967$0$2909$c3e8da3$76491128@news.astraweb.com> <mailman.8825.1396494621.18130.python-list@python.org> <87fvluss86.fsf@elektro.pacujo.net> <1396533471.32018.102326165.14B5BB43@webmail.messagingengine.com> <CAPTjJmpQhneBQF2070AS=dfFFCU6E5_O8OFiM2rVf40duLCB-A@mail.gmail.com> |
| Date | Fri, 4 Apr 2014 11:15:57 +1100 |
| Subject | Re: Unicode Chars in Windows Path |
| From | David <bouncingcats@gmail.com> |
| To | "python-list@python.org" <python-list@python.org> |
| Content-Type | text/plain; charset=UTF-8 |
| X-BeenThere | python-list@python.org |
| X-Mailman-Version | 2.1.15 |
| Precedence | list |
| List-Id | General discussion list for the Python programming language <python-list.python.org> |
| List-Unsubscribe | <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe> |
| List-Archive | <http://mail.python.org/pipermail/python-list/> |
| List-Post | <mailto:python-list@python.org> |
| List-Help | <mailto:python-list-request@python.org?subject=help> |
| List-Subscribe | <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe> |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.8868.1396570565.18130.python-list@python.org> (permalink) |
| Lines | 67 |
| NNTP-Posting-Host | 2001:888:2000:d::a6 |
| X-Trace | 1396570565 news.xs4all.nl 2848 [2001:888:2000:d::a6]:41542 |
| X-Complaints-To | abuse@xs4all.nl |
| Xref | csiph.com comp.lang.python:69623 |
Show key headers only | View raw
On 4 April 2014 01:17, Chris Angelico <rosuav@gmail.com> wrote:
>
> -- Get info on all .pyc files in a directory and all its subdirectories --
> C:\>dir some_directory\*.pyc /s
> $ ls -l `find some_directory -name \*.pyc`
>
> Except that the ls version there can't handle names with spaces in
> them, so you need to faff around with null termination and stuff.
Nooo, that stinks! There's no need to abuse 'find' like that, unless
the version you have is truly ancient. Null termination is only
necessary to pass 'find' results *via the shell*. Instead, ask 'find'
to invoke the task itself.
The simplest way is:
find some_directory -name '*.pyc' -ls
'find' is the tool to use for *finding* things, not 'ls', which is
intended for terminal display of directory information.
If you require a particular feature of 'ls', or any other command, you
can ask 'find' to invoke it directly (not via a shell):
find some_directory -name '*.pyc' -exec ls -l {} \;
'Find' is widely under utilised and poorly understood because its
command line syntax is extremely confusing compared to other tools,
plus its documentation compounds the confusion. For anyone interested,
I offer these key insights:
Most important to understand is that the -name, -exec and -ls that I
used above (for example) are *not* command-line "options". Even though
they look like command-line options, they aren't. They are part of an
*expression* in 'find' syntax. And the crucial difference is that the
expression is order-dependent. So unlike most other commands, it is a
mistake to put them in arbitrary order.
Also annoyingly, the -exec syntax utilises characters that must be
escaped from shell processing. This is more arcane knowledge that just
frustrates people when they are in a rush to get something done.
In fact, the only command-line *options* that 'find' takes are -H -L
-P -D and -O, but these are rarely used. They come *before* the
directory name(s). Everything that comes after the directory name is
part of a 'find' expression.
But, the most confusing thing of all, in the 'find' documentation,
expressions are composed of tests, actions, and ... options! These
so-called options are expression-options, not command-line-options. No
wonder everyone's confused, when one word describes two
similar-looking but behaviourally different things!
So 'info find' must be read very carefully indeed. But it is
worthwhile, because in the model of "do one thing and do it well",
'find' is the tool intended for such tasks, rather than expecting
these capabilities to be built into all other command line utilities.
I know this is off-topic but because I learn so much from the
countless terrific contributions to this list from Chris (and others)
with wide expertise, I am motivated to give something back when I can.
And given that in the past I spent a little time and effort and
eventually understood this, I summarise it here hoping it helps
someone else. The unix-style tools are far more capable than the
Microsoft shell when used as intended.
There is good documentation on find at: http://mywiki.wooledge.org/UsingFind
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Unicode Chars in Windows Path Steve <sreisscruz@gmail.com> - 2014-04-02 16:27 -0700
Re: Unicode Chars in Windows Path Steven D'Aprano <steve@pearwood.info> - 2014-04-03 02:37 +0000
Re: Unicode Chars in Windows Path Chris Angelico <rosuav@gmail.com> - 2014-04-03 14:10 +1100
Re: Unicode Chars in Windows Path Marko Rauhamaa <marko@pacujo.net> - 2014-04-03 12:00 +0300
Re: Unicode Chars in Windows Path Peter Otten <__peter__@web.de> - 2014-04-03 15:09 +0200
Re: Unicode Chars in Windows Path random832@fastmail.us - 2014-04-03 09:57 -0400
Re: Unicode Chars in Windows Path Chris Angelico <rosuav@gmail.com> - 2014-04-04 01:17 +1100
Re: Unicode Chars in Windows Path David <bouncingcats@gmail.com> - 2014-04-04 11:15 +1100
Re: Unicode Chars in Windows Path Chris Angelico <rosuav@gmail.com> - 2014-04-04 12:16 +1100
Re: Unicode Chars in Windows Path David <bouncingcats@gmail.com> - 2014-04-04 13:02 +1100
Re: Unicode Chars in Windows Path Terry Reedy <tjreedy@udel.edu> - 2014-04-03 14:41 -0400
Re: Unicode Chars in Windows Path Chris Angelico <rosuav@gmail.com> - 2014-04-04 09:06 +1100
Re: Unicode Chars in Windows Path Lele Gaifax <lele@metapensiero.it> - 2014-04-04 09:07 +0200
Re: Unicode Chars in Windows Path alister <alister.nospam.ware@ntlworld.com> - 2014-04-03 08:35 +0000
csiph-web