[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: traverse a directory
From: |
Xah Lee |
Subject: |
Re: traverse a directory |
Date: |
Wed, 2 Jan 2008 21:51:17 -0800 (PST) |
User-agent: |
G2/1.0 |
about traversing a dir tree...
In Python, it's done with “walk”, like this:
os.path.walk(mydir, myfun, 'somenull')
In Perl, it's done with File::Find qw(find), like this:
find(\&myfun, $mydir);
which is quite fucked up.
For details on Python and Perl's dir traverse, see
★ Perl-Python Tutorial: Traverse A Directory
http://xahlee.org/perl-python/traverse_dir.html
For unix, as you said, is “find” (with exec or xargs), which is the
most fucking fuck demented twisted crippled shit in the entire
universe. (This point is particularly interesting because most senior
unix sys admins and don't realize it but actually thought its godsend)
For more, see:
★ Unix Command Line Tools Tips
http://xahlee.org/UnixResource_dir/unix_tips.html
Emacs lisp's
(require 'find-lisp)
(mapcar 'myfun (find-lisp-find-files mydir))
Is the most beautiful among these.
For a general treatise on sorting tree nodes (i.e. the order of
visiting), see:
★ Sorting Tree Indexes
http://xahlee.org/tree/a-IndexSetSort.html
Xah
xah@xahlee.org
\xAD\xF4 http://xahlee.org/
On Jan 2, 11:25 am, jadam...@partners.org (Joel J. Adamson) wrote:
>...
> > cool maybe, but portable was my reason for doing it this way. BSD find
> > is very different from gnu find.
>
> So I've heard: should I go ahead with installing FreeBSD?
>
> > some systems don't even have find. exec is a jungle, posix a mirage :)
>
> Some systems I've found aren't systematic.
- traverse a directory, Xah Lee, 2008/01/01
- Re: traverse a directory, Eli Zaretskii, 2008/01/01
- Re: traverse a directory, Mike Mattie, 2008/01/02
- Message not available
- Re: traverse a directory, Joel J. Adamson, 2008/01/02
- Re: traverse a directory, Mike Mattie, 2008/01/02
- Message not available
- Re: traverse a directory, Joel J. Adamson, 2008/01/02
- Re: traverse a directory,
Xah Lee <=
- Re: traverse a directory, Alexey Pustyntsev, 2008/01/03
- Re: traverse a directory, Joel J. Adamson, 2008/01/03
- Message not available
- OT: Re: traverse a directory, Johan Lindstrm, 2008/01/05
- Re: traverse a directory, Mike Mattie, 2008/01/04
Message not available