From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 21703 invoked from network); 2 Dec 2003 17:12:06 -0000 Received: from sunsite.dk (130.225.247.90) by ns1.primenet.com.au with SMTP; 2 Dec 2003 17:12:06 -0000 Received: (qmail 27184 invoked by alias); 2 Dec 2003 17:11:38 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 6828 Received: (qmail 27134 invoked from network); 2 Dec 2003 17:11:38 -0000 Received: from localhost (HELO sunsite.dk) (127.0.0.1) by localhost with SMTP; 2 Dec 2003 17:11:38 -0000 X-MessageWall-Score: 0 (sunsite.dk) Received: from [62.193.203.32] by sunsite.dk (MessageWall 1.0.8) with SMTP; 2 Dec 2003 17:11:36 -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 hB2HBZ302112 for ; Tue, 2 Dec 2003 18:11:35 +0100 Received: from raul@pleyades.net by DervishD.pleyades.net with local (Exim MTA 2.05) id <1ARE3J-0004hU-00>; Tue, 2 Dec 2003 18:11:09 +0100 Date: Tue, 2 Dec 2003 18:11:09 +0100 From: DervishD To: Zsh Users Subject: Advice for filesystem operations under Zsh Message-ID: <20031202171109.GW1814@DervishD> Mail-Followup-To: Zsh Users 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 Hello all :)) I have a little shell function that, for each file in certain places of the filesystem, checks whether the file belongs to an installed program or not, using some list files. I must tell how it is implemented in order to ask for advice, so please be patient O:) The file list is stored in an array parameter, and in order to avoid reading from disk, the check is performed reading every 'list file' and comparing its contents (lines that are filenames) against the entire array, deleting the corresponding entry if found. That way, at the end of iterations, the array contains all 'orphan' files. This works ok for me, but I want to extend this shell function to perform other tasks. One of them is, given a filename, find the 'list file' it belongs to. That's pretty easy ;)) But I want to extend the shell function so that, in one run, it outputs: - Orphan files in file descriptor 3 - Dangling symlinks in file descriptor 4 - Setuid binaries in file descriptor 5 - Duplicate files in file descriptor 6 - Empty directories in file descriptor 7 - etc... Under Zsh is pretty easy to find all dangling symlinks (**/*(@-)), setuid files (**/*(s)), etc... and I can do all that in just one travel through the filesystem, since glob qualifiers work too with filenames withouth globbing characters. My problems are: - finding dupes. I've tried to use 'I' subscript flag, but this only return all matching keys in an associative array, not in normal ones. The only solution seems to be deleting the match and search again... - finding empty directories. Looking for the number of links in the directory doesn't work (it only shows if the directory has files or not, but not if it has subdirs). - doing all that in one run of the array. Since the 'orphans' check destroys the contents of the array, I need to dupe it, or convert it to a associative array, but then it cannot have duplicate entries, since I would need to use the filename as a key and the value as one of dangling, orphan, empty, setuid, etc... or even a combination of that. The objetive is doing a lightweight version of FSlint without using 'find'. The solutions to some of the problems are easy: use a 'master' array and duplicates as needed, for example for finding orphans, duplicated filenames, etc... And I cannot find a solution for empty files. Sorry for the long message, and thanks a lot in advance, truly. Raúl Núñez de Arenas Coronado -- Linux Registered User 88736 http://www.pleyades.net & http://raul.pleyades.net/