[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: SV: finding .m files using 'locate'
From: |
Mike Miller |
Subject: |
Re: SV: finding .m files using 'locate' |
Date: |
Tue, 19 Jul 2005 09:56:26 -0500 (CDT) |
On Tue, 19 Jul 2005, Peter J. Acklam wrote:
Mike Miller wrote:
Darn it -- I meant to correct that before I sent it. When it is
written that way (with no 'm') it deletes the newlines. The 'm' is
needed, but the '.' can be deleted. I had it right in this line near
the end of my message:
locate "*.m" | perl -pe 's#(^.*)/[^/]+m#$1#' | sort | uniq
The -l (ell) option is very useful for one-liners like this
locate "*.m" | perl -ple 's#(^.*)/[^/]+$#$1#' | sort | uniq
which can be simplified to
locate "*.m" | perl -ple 's|/[^/]+$||' | sort | uniq
Shoter *and* slightly faster!
where the "sort" and "uniq" can be removed by using
locate "*.m" | perl -nle 's|/[^/]+$|| ; print unless $d{$_}++'
Slightly faster still, but also a little longer.
This has been a good learning experience for me. I enjoy reading all the
suggestions and figuring out how they work.
Mike
-------------------------------------------------------------
Octave is freely available under the terms of the GNU GPL.
Octave's home on the web: http://www.octave.org
How to fund new projects: http://www.octave.org/funding.html
Subscription information: http://www.octave.org/archive.html
-------------------------------------------------------------
- Re: finding .m files using 'locate', (continued)
- Re: finding .m files using 'locate', Przemek Klosowski, 2005/07/18
- Re: finding .m files using 'locate', Mike Miller, 2005/07/19
- Re: finding .m files using 'locate', Mike Miller, 2005/07/19
- SV: finding .m files using 'locate', Peter J. Acklam, 2005/07/19
- Re: SV: finding .m files using 'locate',
Mike Miller <=
- Re: finding .m files using 'locate', Peter J. Acklam, 2005/07/19
Re: finding .m files using 'locate', Michael W. Martin, 2005/07/15