On Thu, 17 Dec 2009 14:02:38 +0100 Milan Babuskov milan.babuskov@gmail.com wrote:
many times I use Geany's "find in files" function to search for some string inside directory. The problem is that results are not sorted at all (at least, I cannot find a critera: it isn't file timestamp or filename).
AFAIU, filenames are sorted so long as you don't use the 'Recurse in subfolders' option. Maybe this could be fixed, but I'm not sure it's worth implementing in Geany - see below.
Would it be possible to sort the result alphabetically (or any other way). Just piping grep to sort(1) would be sufficient to me.
Sorting grep's output is not efficient - only the file list needs to be sorted, and as Enrico mentioned, it's not portable.
The real problem is that grep doesn't support recursive searching well enough, but you could use the following script for Geany's Grep tool:
http://download.geany.org/contrib/grep2ack.pl
Remember to chmod u+x.
This uses ack* and (as of today) sorts filenames too. * http://betterthangrep.com/
Ack skips binary and generated files.
Regards, Nick