From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 25179 invoked from network); 1 Oct 2003 22:14:50 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 1 Oct 2003 22:14:50 -0000 Received: (qmail 15292 invoked by alias); 1 Oct 2003 22:14:42 -0000 Mailing-List: contact zsh-workers-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 19162 Received: (qmail 15279 invoked from network); 1 Oct 2003 22:14:41 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 1 Oct 2003 22:14:41 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [217.174.194.138] by sunsite.dk (MessageWall 1.0.8) with SMTP; 1 Oct 2003 22:14:39 -0000 Received: from DervishD.pleyades.net (212.Red-80-35-44.pooles.rima-tde.net [80.35.44.212]) by madrid10.amenworld.com (8.10.2/8.10.2) with ESMTP id h91MEZt04227 for ; Thu, 2 Oct 2003 00:14:37 +0200 Received: from raul@pleyades.net by DervishD.pleyades.net with local (Exim MTA 2.05) id <1A4pI9-00062S-00>; Thu, 2 Oct 2003 00:17:53 +0200 Date: Thu, 2 Oct 2003 00:17:53 +0200 From: DervishD To: Zsh Subject: Emulating 'locate' Message-ID: <20031001221753.GA23189@DervishD> Mail-Followup-To: Zsh Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit User-Agent: Mutt/1.4i Organization: Pleyades User-Agent: Mutt/1.4i Hi all :)) Assuming that 'print /**/*' will print all filenames from the root directory, recursive globbing could be used, for example, as a poor-man substitute of 'locate'. But there is a problem. Let's assume this hierarchy: /dir1/dir2/dir3/file1 /dir1/dir2/dir3/file2 ... /dir1/dir2/dir3/filen If we issue the command 'locate ir3', then locate will find all the files above, and will show all paths. But if we issue what I thought that was equivalente: 'print -l /**/*ir3*', then the output is just '/dir1/dir2/dir3'. I'm obviously wrong, but don't know where: the above matches any number of directories (well /(*/)#...), followed by any character, ir3 and again any character. Well, I suppose that slashes must be matched explicitly (that is what ** is for...), so I do 'print -l /**/*ir3*/**'. Voilá, now it matches ok :))) and the result is the same as locate. Problem solved? Not at all. Let do 'locate ir2'. The list of output files is the same as 'locate ir3' (well, it outputs a couple of dirs more). But if I do 'print -l /**/*ir2*/**' I only get '/dir1/dir2/dir3' :((( In fact, adding more ** doesn't work: 'print /**/*ir2*/**/**' just outputs '/dir1/dir2/ /dir1/dir2/dir3/ /dir1/dir2/dir3' Resuming: I'm again clueless and in addition to this I don't understand correctly the filename generation and recursive globbing. Anyone can explain a bit what I'm doing wrong so I can use zsh instead of 'locate'?. For those interested: yes, locate may be faster than zsh (although using a database, like locate does, may change things), but it reveals files not accesible, nor even listable, by the current user if the database was build with root privileges. Zsh won't, being a bit more secure. There are a slocate out there, too, but... well, it's zsh ;))) Thanks a lot again :) Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 http://www.pleyades.net & http://raul.pleyades.net/