help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

SV: finding .m files using 'locate'


From: Peter J. Acklam
Subject: SV: finding .m files using 'locate'
Date: Tue, 19 Jul 2005 16:25:32 +0200 (CEST)

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

where the "sort" and "uniq" can be removed by using

  locate "*.m" | perl -nle 's|/[^/]+$|| ; print unless $d{$_}++'

Peter

reply via email to

[Prev in Thread] Current Thread [Next in Thread]