From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 28318 invoked from network); 6 Aug 2005 05:37:23 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by ns1.primenet.com.au with SMTP; 6 Aug 2005 05:37:23 -0000 Received: (qmail 49312 invoked from network); 6 Aug 2005 05:37:16 -0000 Received: from sunsite.dk (130.225.247.90) by a.mx.sunsite.dk with SMTP; 6 Aug 2005 05:37:16 -0000 Received: (qmail 22216 invoked by alias); 6 Aug 2005 05:37:09 -0000 Mailing-List: contact zsh-users-help@sunsite.dk; run by ezmlm Precedence: bulk X-No-Archive: yes X-Seq: 9254 Received: (qmail 22206 invoked from network); 6 Aug 2005 05:37:09 -0000 Received: from news.dotsrc.org (HELO a.mx.sunsite.dk) (130.225.247.88) by sunsite.dk with SMTP; 6 Aug 2005 05:37:09 -0000 Received: (qmail 48279 invoked from network); 6 Aug 2005 05:37:09 -0000 Received: from p54850107.dip0.t-ipconnect.de (HELO solfire) (84.133.1.7) by a.mx.sunsite.dk with SMTP; 6 Aug 2005 05:37:04 -0000 Received: from localhost ([127.0.0.1]) by solfire with esmtp (Exim 4.42) id 1E1HOF-0004GN-Ce; Sat, 06 Aug 2005 07:38:39 +0200 Date: Sat, 06 Aug 2005 07:38:35 +0200 (CEST) Message-Id: <20050806.073835.71083870.Meino.Cramer@gmx.de> To: david@tvis.co.uk Cc: zsh-users@sunsite.dk From: Meino Christian Cramer In-Reply-To: X-Mailer: Mew version 4.1 on Emacs 21.3 / Mule 5.0 (SAKAKI) Mime-Version: 1.0 X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Rcpt-To: david@tvis.co.uk, zsh-users@sunsite.dk X-SA-Exim-Mail-From: Meino.Cramer@gmx.de Subject: Summary: Sorting files Content-Type: Text/Plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-SA-Exim-Version: 4.1+cvs (built Sat, 28 Aug 2004 13:10:40 +0200) X-SA-Exim-Scanned: Yes (on solfire) X-Spam-Checker-Version: SpamAssassin 3.0.4 (2005-06-05) on f.primenet.com.au X-Spam-Level: X-Spam-Status: No, score=-2.5 required=5.0 tests=AWL,BAYES_00 autolearn=ham version=3.0.4 From: zzapper Subject: Re: Sorting files Date: Fri, 05 Aug 2005 11:51:15 +0100 *** PRELIMINARY DRAFT *** Sorting files: Summary of traps and pitfalls To achieve more control over wildcards -- or should I better separate "wild" from "cards" ;O) -- zsh has implemented "Glob qualifiers". One of these "Glob Qualifiers" is "oL", which sorts all files matching the wildcard. Example: *.bz2(oL) will match all bzip2-compressed files in the current directory and sort the list by the size of that files. More interesting effects can be achieved, when "(oL)" is combined with recursive globbing. The wildcard **/*.bz2 will result in a list of all bzip2-compressed files in the current directory and all subdirectories below. So far so nice... ;O) Now...what will be the result if one submit ls -l **/*.bz2(.oL) ? Confusion -- at least in my case... ;) Beside the common "arg list too long" failure of ls, which appears, when "**/*.bz2" simply will to match too many files, the output isn't sorted the exspected way... Why? First **/*.bz2 will be evaluated. The result is a sorted (!) list of files. Then ls grabs that list and resorted it the standard way (alphabetically), which destroy the sort done by (.oL). One way around this trap is a "longer" script: for i in **/*bz2(.ol) do ls -l ${i} done which won't give ls the chance of sorting anything, cause it only sees one file at a time. The drawback is a call to ls on *every* file and a somehow bulky command. If you get an "arg list to long"-error after submitting ls -l **/*bz2(.oL) then the above script is a solution for that. But if not the following does, what you want: ls -sS -- **/*.bz2(.) Why? "--" prevents ls from thinking of another option, if a filename starts with a "-". "-s" let ls print the size of the file, "-S" sort the files matching **/*.bz2(.) by its size. Or in other words: (.oL) to sort files is not needed here and it seems that in combination with recursive globbing plus ls it spend a lot of confusion to its users (this is at least valid for me ;). Keep zshing! Meino > On Thu, 4 Aug 2005 21:51:33 +0200, wrote: > > >Meino Christian Cramer wrote: > >> Hi, > >> > >> I played around with combinations including expressions like > >> **/*(.,oL) trying to get a listing of all files found !including > >> those of the subdirectories! sorted by their size. I want one big > >> listing sorted "once" -- but I got "seperated" parts sorted each for > >> themselves. > > Any chance of a summary of this interesting thread (assuming it's finished)? > -- > zzapper > vim -c ":%s%s*%Cyrnfr)fcbafbe[Oenz(Zbbyranne%|:%s)[[()])-)Ig|norm Vg?" > http://www.rayninfo.co.uk/tips/ vim, zsh & success tips >