* Sorting files
@ 2005-08-04 18:38 Meino Christian Cramer
2005-08-04 18:48 ` Mikael Magnusson
` (3 more replies)
0 siblings, 4 replies; 19+ messages in thread
From: Meino Christian Cramer @ 2005-08-04 18:38 UTC (permalink / raw)
To: zsh-users
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.
I would understand this, if I had submitted something like:
print -l **/*(oL)
which includes directories due to the missing ".", but when I submit:
print -l **/*(.,oL)
I would expect "all files sorted by their size".
But as always, the problem is probably caused by the person sitting
right in front of my monitor, I fear ;)
Is there a way to get one big listing starting with the smallest file
of all files found (including those in the subdirectories) and ending
with the largest one? ...without the conventional way of slowly
smokeing a sort-pipe ?
Thanks a lot in advance for any help or hint ! :O)
Keep zshing!
Meino
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-04 18:38 Sorting files Meino Christian Cramer
@ 2005-08-04 18:48 ` Mikael Magnusson
2005-08-04 19:10 ` Meino Christian Cramer
2005-08-04 19:14 ` Christian Schneider
` (2 subsequent siblings)
3 siblings, 1 reply; 19+ messages in thread
From: Mikael Magnusson @ 2005-08-04 18:48 UTC (permalink / raw)
To: zsh-users
On 8/4/05, Meino Christian Cramer <Meino.Cramer@gmx.de> 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.
>
> I would understand this, if I had submitted something like:
>
> print -l **/*(oL)
>
> which includes directories due to the missing ".", but when I submit:
>
> print -l **/*(.,oL)
>
> I would expect "all files sorted by their size".
>
> But as always, the problem is probably caused by the person sitting
> right in front of my monitor, I fear ;)
>
> Is there a way to get one big listing starting with the smallest file
> of all files found (including those in the subdirectories) and ending
> with the largest one? ...without the conventional way of slowly
> smokeing a sort-pipe ?
>
> Thanks a lot in advance for any help or hint ! :O)
>
> Keep zshing!
> Meino
>From the manpage,
o specifies how the names of the files should be sorted.
if d, files in subdirectories appear before those
in the current directory at each level of the search
-- this is best com-
bined with other criteria, for example `odon' to sort
on names for files
within the same directory.
I think that is what you want, but i'm not sure with that description :)
ie, print -l **/*(.,odL)
--
Mikael Magnusson
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-04 18:48 ` Mikael Magnusson
@ 2005-08-04 19:10 ` Meino Christian Cramer
2005-08-04 19:18 ` Danek Duvall
0 siblings, 1 reply; 19+ messages in thread
From: Meino Christian Cramer @ 2005-08-04 19:10 UTC (permalink / raw)
To: mikachu; +Cc: zsh-users
From: Mikael Magnusson <mikachu@gmail.com>
Subject: Re: Sorting files
Date: Thu, 4 Aug 2005 20:48:00 +0200
> On 8/4/05, Meino Christian Cramer <Meino.Cramer@gmx.de> 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.
> >
> > I would understand this, if I had submitted something like:
> >
> > print -l **/*(oL)
> >
> > which includes directories due to the missing ".", but when I submit:
> >
> > print -l **/*(.,oL)
> >
> > I would expect "all files sorted by their size".
> >
> > But as always, the problem is probably caused by the person sitting
> > right in front of my monitor, I fear ;)
> >
> > Is there a way to get one big listing starting with the smallest file
> > of all files found (including those in the subdirectories) and ending
> > with the largest one? ...without the conventional way of slowly
> > smokeing a sort-pipe ?
> >
> > Thanks a lot in advance for any help or hint ! :O)
> >
> > Keep zshing!
> > Meino
>
> >From the manpage,
>
> o specifies how the names of the files should be sorted.
> if d, files in subdirectories appear before those
> in the current directory at each level of the search
> -- this is best com-
> bined with other criteria, for example `odon' to sort
> on names for files
> within the same directory.
>
> I think that is what you want, but i'm not sure with that description :)
> ie, print -l **/*(.,odL)
Hi Mikael !
Thanks for reply ! :O)
print -l **/*(.,odL) gives (zsh 4.2.5, Linux 2.6.12.3)
zsh: number expected
?
Now I am totally confused.... X-)
Happy zshing!
Meino
> --
> Mikael Magnusson
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-04 18:38 Sorting files Meino Christian Cramer
2005-08-04 18:48 ` Mikael Magnusson
@ 2005-08-04 19:14 ` Christian Schneider
2005-08-04 21:19 ` Jens Kubieziel
2005-08-05 3:06 ` Meino Christian Cramer
2005-08-04 19:51 ` Christian Taylor
2005-08-05 12:52 ` DervishD
3 siblings, 2 replies; 19+ messages in thread
From: Christian Schneider @ 2005-08-04 19:14 UTC (permalink / raw)
To: zsh-users
* Meino Christian Cramer <Meino.Cramer@gmx.de> typed:
[...]
> Is there a way to get one big listing starting with the smallest file
> of all files found (including those in the subdirectories) and ending
> with the largest one? ...without the conventional way of slowly
> smokeing a sort-pipe ?
$ ls -fl ./**/*(OL)
or
$ zmodload zsh/stat
$ ls -fld ./**/*(d`stat +device .`OL)
--
http://www.strcat.de/zsh/#features [*] Christian 'strcat' Schneider
http://www.strcat.de/zsh/#tipps [*] Email.......: strcat@gmx.net
http://www.strcat.de/zsh/#modex [*] GPG-ID......: 47E322CE
http://www.strcat.de/zsh/#links [*] [zsh - the Z shell]
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-04 19:10 ` Meino Christian Cramer
@ 2005-08-04 19:18 ` Danek Duvall
2005-08-04 20:41 ` Stephane Chazelas
0 siblings, 1 reply; 19+ messages in thread
From: Danek Duvall @ 2005-08-04 19:18 UTC (permalink / raw)
To: Meino Christian Cramer; +Cc: zsh-users
Does
print -l **/*(.oL)
not do what you want?
Danek
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-04 18:38 Sorting files Meino Christian Cramer
2005-08-04 18:48 ` Mikael Magnusson
2005-08-04 19:14 ` Christian Schneider
@ 2005-08-04 19:51 ` Christian Taylor
2005-08-05 10:51 ` zzapper
2005-08-05 12:52 ` DervishD
3 siblings, 1 reply; 19+ messages in thread
From: Christian Taylor @ 2005-08-04 19:51 UTC (permalink / raw)
To: zsh-users
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.
>
> I would understand this, if I had submitted something like:
>
> print -l **/*(oL)
>
> which includes directories due to the missing ".", but when I submit:
>
> print -l **/*(.,oL)
>
> I would expect "all files sorted by their size".
If I'm not mistaken, this means "match everything that is either a regular
file OR ANYTHING, and sort by size", because of the comma in the glob
qualifier. Omitting it should do the trick:
print -l **/*(.oL)
lg,
Christian
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-04 19:18 ` Danek Duvall
@ 2005-08-04 20:41 ` Stephane Chazelas
2005-08-05 3:01 ` Meino Christian Cramer
0 siblings, 1 reply; 19+ messages in thread
From: Stephane Chazelas @ 2005-08-04 20:41 UTC (permalink / raw)
To: Danek Duvall, Meino Christian Cramer, zsh-users
On Thu, Aug 04, 2005 at 12:18:16PM -0700, Danek Duvall wrote:
> Does
>
> print -l **/*(.oL)
>
> not do what you want?
[...]
Should be:
print -rl -- **/*(.oL)
--
Stéphane
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-04 19:14 ` Christian Schneider
@ 2005-08-04 21:19 ` Jens Kubieziel
2005-08-05 3:06 ` Meino Christian Cramer
1 sibling, 0 replies; 19+ messages in thread
From: Jens Kubieziel @ 2005-08-04 21:19 UTC (permalink / raw)
To: zsh-users
* Christian Schneider schrieb am 2005-08-04 um 21:14 Uhr:
> $ zmodload zsh/stat
> $ ls -fld ./**/*(d`stat +device .`OL)
There seems to be a bug with large files (Due I'm running out of
diskspace, I couldn't investigate more). Could you verify?
[...]
-rw-r--r-- 1 jens jens 38 2004-02-20 19:19 ./mcdp-0.4/doc/AUTHOR
-rw-r--r-- 1 jens jens 30 2005-06-06 17:09 ./shb/INSTALL
-rw-r--r-- 1 jens jens 30 2005-04-11 22:13 ./shburn/INSTALL
-rw-r--r-- 1 jens jens 0 2005-06-06 17:09 ./shb/shellburnrc
-rw------- 1 jens jens 0 2005-07-29 20:55 ./slides-2up.pdf
-rw-r--r-- 1 jens jens 7408779264 2005-06-10 18:16 ./lop
--
Jens Kubieziel http://www.kubieziel.de
FdI#246: Service Pack
Hauptnahrung bei Softwarebulemie. (Manfred Worm Schäfer)
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-04 20:41 ` Stephane Chazelas
@ 2005-08-05 3:01 ` Meino Christian Cramer
2005-08-05 10:47 ` Stephane CHAZELAS
0 siblings, 1 reply; 19+ messages in thread
From: Meino Christian Cramer @ 2005-08-05 3:01 UTC (permalink / raw)
To: Stephane_Chazelas; +Cc: duvall, zsh-users
From: Stephane Chazelas <Stephane_Chazelas@yahoo.fr>
Subject: Re: Sorting files
Date: Thu, 4 Aug 2005 21:41:22 +0100
> On Thu, Aug 04, 2005 at 12:18:16PM -0700, Danek Duvall wrote:
> > Does
> >
> > print -l **/*(.oL)
> >
> > not do what you want?
> [...]
>
> Should be:
>
> print -rl -- **/*(.oL)
>
> --
> Stéphane
>
This gave me no sorted output...sorry :O)
Meino
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-04 19:14 ` Christian Schneider
2005-08-04 21:19 ` Jens Kubieziel
@ 2005-08-05 3:06 ` Meino Christian Cramer
1 sibling, 0 replies; 19+ messages in thread
From: Meino Christian Cramer @ 2005-08-05 3:06 UTC (permalink / raw)
To: strcat; +Cc: zsh-users
From: Christian Schneider <strcat@gmx.net>
Subject: Re: Sorting files
Date: Thu, 4 Aug 2005 21:14:42 +0200
Hi,
> * Meino Christian Cramer <Meino.Cramer@gmx.de> typed:
> [...]
> > Is there a way to get one big listing starting with the smallest file
> > of all files found (including those in the subdirectories) and ending
> > with the largest one? ...without the conventional way of slowly
> > smokeing a sort-pipe ?
>
> $ ls -fl ./**/*(OL)
...this does not work for me...sorry... :)
> or
> $ zmodload zsh/stat
> $ ls -fld ./**/*(d`stat +device .`OL)
This does...but, hmmmmm....I again need an "additional" tool
(zsh/stat). Is the filesize something, which cannot be determined by
the Shell alone ?
Why does it seems, that any combination or contruction with oL,. and
() does not work (until now) ?
keep zshing!
Meino
> --
> http://www.strcat.de/zsh/#features [*] Christian 'strcat' Schneider
> http://www.strcat.de/zsh/#tipps [*] Email.......: strcat@gmx.net
> http://www.strcat.de/zsh/#modex [*] GPG-ID......: 47E322CE
> http://www.strcat.de/zsh/#links [*] [zsh - the Z shell]
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-05 3:01 ` Meino Christian Cramer
@ 2005-08-05 10:47 ` Stephane CHAZELAS
0 siblings, 0 replies; 19+ messages in thread
From: Stephane CHAZELAS @ 2005-08-05 10:47 UTC (permalink / raw)
To: Meino Christian Cramer; +Cc: duvall, zsh-users
On Fri, Aug 05, 2005 at 05:01:46AM +0200, Meino Christian Cramer wrote:
[...]
> > > print -l **/*(.oL)
[...]
> > Should be:
> >
> > print -rl -- **/*(.oL)
[...]
> This gave me no sorted output...sorry :O)
I was just pointing out that
print -l arbitrary list of file names
is not correct. print without -r is to print a text that is in
the form "text with \t \n... escape sequences" like in C string
constants. That's an old design error in shells inherited from
ksh to have that as the default behavior. For a correct way, see
perl for instance where \t, \n are expanded at the language
level (or by the double quotes if you like).
In perl,
$var = "\t"
assigns a <Tab> character to $var and print $var prints the
content of $var. ($var = '\t' assigns "\" and "t" to $var).
In shells,
var="\t"
assigns the "\" and "t" characters to $var and print "$var"
prints the expansion of the "\t" escape sequence, i.e. a <Tab>
character.
ksh93, bash and zsh have the cumbersome:
var=$'\t'
that does the same as perl's "\t", but print (and echo) are
still /broken/ and need the "-r" (and -n to prevent adding a
newline character) to print strings asis.
Without --, the list can be options or arguments, while you
definitely mean them to be arguments there.
Another annoying thing with print -l is that without arguments,
it still prints an empty line as if it had been given an empty
argument.
So that to print arguments one per line, you actually need:
correct_print-l() {
(( $# == 0 )) || print -rl -- "$@"
}
or to be portable (POSIX):
correct_print_l() {
[ "$#" -eq 0 ] || printf '%s\n' "$@"
}
--
Stephane
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-04 19:51 ` Christian Taylor
@ 2005-08-05 10:51 ` zzapper
2005-08-05 12:57 ` Christian Taylor
` (2 more replies)
0 siblings, 3 replies; 19+ messages in thread
From: zzapper @ 2005-08-05 10:51 UTC (permalink / raw)
To: zsh-users
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
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-04 18:38 Sorting files Meino Christian Cramer
` (2 preceding siblings ...)
2005-08-04 19:51 ` Christian Taylor
@ 2005-08-05 12:52 ` DervishD
2005-08-05 14:01 ` Meino Christian Cramer
3 siblings, 1 reply; 19+ messages in thread
From: DervishD @ 2005-08-05 12:52 UTC (permalink / raw)
To: Meino Christian Cramer; +Cc: zsh-users
Hi Meino :)
* Meino Christian Cramer <Meino.Cramer@gmx.de> dixit:
> I would understand this, if I had submitted something like:
> print -l **/*(oL)
print -l -- **/*(.oL) works for me, tested in my root directory.
It's a good idea to use '-r' too, as suggested in the thread, just in
case there is any weird filename.
Raúl Núñez de Arenas Coronado
--
Linux Registered User 88736 | http://www.dervishd.net
http://www.pleyades.net & http://www.gotesdelluna.net
It's my PC and I'll cry if I want to...
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-05 10:51 ` zzapper
@ 2005-08-05 12:57 ` Christian Taylor
2005-08-05 14:41 ` Meino Christian Cramer
2005-08-06 5:38 ` Summary: " Meino Christian Cramer
2 siblings, 0 replies; 19+ messages in thread
From: Christian Taylor @ 2005-08-05 12:57 UTC (permalink / raw)
To: zsh-users
zzapper wrote:
> >Meino Christian Cramer wrote:
> >> 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)?
I don't know if the thread is finished yet, but I'll try to sum up the things
I've learned so far. I'm no zsh expert, so pointing out errors would be much
appreciated:
According to the user guide and the actual behaviour of zsh (4.2.5) on my
system, this should do exactly what Meino wants, sorting all files by size
"in one go" (files from different subdirectories mixed together):
print -l -- **/*(.oL)
However, Meino replied to a similar suggestion "This gave me no sorted
output...sorry :O)" - unfortunately, I have no idea why this is so.
"print -l -- **/*(.,oL)" also sorts in one go, but unintentionally includes
EVERYTHING, because no glob qualifier other than sorting is given after the
comma ("match everything that is a regular file or anything at all").
The "od" sort option that was suggested puts files in subdirectories before
those in the current directory at each level of the search. "Od" does the
reverse.
The results of "**/*(.odoL)" seem a bit unexpected at first, because files of
all subdirectories are mixed together, but still all files of every
subdirectory appear before files in the respective parent directory, and the
whole list is sorted by size as far as this constraint allows.
"**/*(.odL)" doesn't work - zsh interprets the L as the regular size glob
qualifier with a missing size specification, because every sort qualifier has
to be directly preceded by "o" or "O".
However, if I understood Meino's goal correctly, he'll want neither "od" nor
"Od" in his glob qualifier.
That's about it, I hope this helps someone,
Christian
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-05 12:52 ` DervishD
@ 2005-08-05 14:01 ` Meino Christian Cramer
2005-08-05 14:29 ` Mikael Magnusson
0 siblings, 1 reply; 19+ messages in thread
From: Meino Christian Cramer @ 2005-08-05 14:01 UTC (permalink / raw)
To: zsh; +Cc: zsh-users
From: DervishD <zsh@dervishd.net>
Subject: Re: Sorting files
Date: Fri, 5 Aug 2005 14:52:43 +0200
Hi Raúl ! :)
(sorry, if your name comes out somehow -- hrmm -- "encrypted"...
my Emacs seems to handle everything other than plain ascii a little
weird... ;)
Hmmm...interesting.. as soon as you mailed me that it works for you
my zsh seems to be that impressed, that s/he decided also to work
correctly....mysterious ! ;O)
More seriously... I dont know what's happening here. May be I
mispelled an option or forget a "-" somewhere...
More important: It WORKS ! :) (even for me! ;)
Another question in this context:
To check the options, I had to construct this one:
for i in **/*(.oL)
do
ls -ld $i
done | less
Is there any other more shorter way to achieve the same results with
less code -- especially without calling any other "tool" like
zsh/stat or xargs or such ? But I insist on getting filenames AND
sizes ! ;O) Not only the filename should be shown!
Ok, now this is more like a "coding contest" for me than a practical
excurse....but I like to tune things :O))
Have a nice weekend !
Meino
> Hi Meino :)
>
> * Meino Christian Cramer <Meino.Cramer@gmx.de> dixit:
> > I would understand this, if I had submitted something like:
> > print -l **/*(oL)
>
> print -l -- **/*(.oL) works for me, tested in my root directory.
> It's a good idea to use '-r' too, as suggested in the thread, just in
> case there is any weird filename.
>
> Raúl Núñez de Arenas Coronado
>
> --
> Linux Registered User 88736 | http://www.dervishd.net
> http://www.pleyades.net & http://www.gotesdelluna.net
> It's my PC and I'll cry if I want to...
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-05 14:01 ` Meino Christian Cramer
@ 2005-08-05 14:29 ` Mikael Magnusson
0 siblings, 0 replies; 19+ messages in thread
From: Mikael Magnusson @ 2005-08-05 14:29 UTC (permalink / raw)
To: zsh, zsh-users
On 8/5/05, Meino Christian Cramer <Meino.Cramer@gmx.de> wrote:
> From: DervishD <zsh@dervishd.net>
> Subject: Re: Sorting files
> Date: Fri, 5 Aug 2005 14:52:43 +0200
>
> Hi Raúl ! :)
>
> (sorry, if your name comes out somehow -- hrmm -- "encrypted"...
> my Emacs seems to handle everything other than plain ascii a little
> weird... ;)
>
> Hmmm...interesting.. as soon as you mailed me that it works for you
> my zsh seems to be that impressed, that s/he decided also to work
> correctly....mysterious ! ;O)
>
> More seriously... I dont know what's happening here. May be I
> mispelled an option or forget a "-" somewhere...
>
> More important: It WORKS ! :) (even for me! ;)
>
> Another question in this context:
> To check the options, I had to construct this one:
>
> for i in **/*(.oL)
> do
> ls -ld $i
> done | less
>
> Is there any other more shorter way to achieve the same results with
> less code -- especially without calling any other "tool" like
> zsh/stat or xargs or such ? But I insist on getting filenames AND
> sizes ! ;O) Not only the filename should be shown!
>
> Ok, now this is more like a "coding contest" for me than a practical
> excurse....but I like to tune things :O))
>
>
> Have a nice weekend !
> Meino
Maybe you want something as simple as the following?
ls -Ssh -- **/*(.)
That'll sort all the files in descending size order and show the
sizes. It will sort _all_ files by size, not just internally sort in
each subdirectory, maybe that was what you wanted and then this won't
help. Also obviously suffers from the too many arguments possibility.
--
Mikael Magnusson
ps
sorry if i messed up the cc and/or to fields, gmail really doesn't
want me to use mailing lists. When i hit Reply, it just replies to the
last person and not the list, and when i select Reply To All it puts
the person in To: and the list in Cc:, I'm not sure what I'm expected
to do, don't use mailing lists a lot.
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Sorting files
2005-08-05 10:51 ` zzapper
2005-08-05 12:57 ` Christian Taylor
@ 2005-08-05 14:41 ` Meino Christian Cramer
2005-08-06 5:38 ` Summary: " Meino Christian Cramer
2 siblings, 0 replies; 19+ messages in thread
From: Meino Christian Cramer @ 2005-08-05 14:41 UTC (permalink / raw)
To: david; +Cc: zsh-users
From: zzapper <david@tvis.co.uk>
Subject: Re: Sorting files
Date: Fri, 05 Aug 2005 11:51:15 +0100
> 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
>
Of course...the end is near ;O)))
As soon as I think, that all is "visible" I will try summarize it.
Keep zshing!
Meino
^ permalink raw reply [flat|nested] 19+ messages in thread
* Summary: Sorting files
2005-08-05 10:51 ` zzapper
2005-08-05 12:57 ` Christian Taylor
2005-08-05 14:41 ` Meino Christian Cramer
@ 2005-08-06 5:38 ` Meino Christian Cramer
2005-08-06 9:22 ` Christian Taylor
2 siblings, 1 reply; 19+ messages in thread
From: Meino Christian Cramer @ 2005-08-06 5:38 UTC (permalink / raw)
To: david; +Cc: zsh-users
From: zzapper <david@tvis.co.uk>
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
>
^ permalink raw reply [flat|nested] 19+ messages in thread
* Re: Summary: Sorting files
2005-08-06 5:38 ` Summary: " Meino Christian Cramer
@ 2005-08-06 9:22 ` Christian Taylor
0 siblings, 0 replies; 19+ messages in thread
From: Christian Taylor @ 2005-08-06 9:22 UTC (permalink / raw)
To: zsh-users
Meino Christian Cramer wrote:
> 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(.)
As a compromise, I would suggest using the following:
(you need to autoload zargs first, either manually or in your .zshrc)
zargs -- **/*.bz2(.oL) -- ls -lU
This should work better than the for-loop because zargs calls ls with a few
thousand arguments at a time, resulting in much fewer calls.
Although the manpage for ls claims that -U displays files without sorting, "in
whatever order they are stored on the disk", on my system it displays them in
the order of the arguments it is called with. Therefore, you can use any
combination of sorting that zsh provides.
Christian
^ permalink raw reply [flat|nested] 19+ messages in thread
end of thread, other threads:[~2005-08-06 9:23 UTC | newest]
Thread overview: 19+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-08-04 18:38 Sorting files Meino Christian Cramer
2005-08-04 18:48 ` Mikael Magnusson
2005-08-04 19:10 ` Meino Christian Cramer
2005-08-04 19:18 ` Danek Duvall
2005-08-04 20:41 ` Stephane Chazelas
2005-08-05 3:01 ` Meino Christian Cramer
2005-08-05 10:47 ` Stephane CHAZELAS
2005-08-04 19:14 ` Christian Schneider
2005-08-04 21:19 ` Jens Kubieziel
2005-08-05 3:06 ` Meino Christian Cramer
2005-08-04 19:51 ` Christian Taylor
2005-08-05 10:51 ` zzapper
2005-08-05 12:57 ` Christian Taylor
2005-08-05 14:41 ` Meino Christian Cramer
2005-08-06 5:38 ` Summary: " Meino Christian Cramer
2005-08-06 9:22 ` Christian Taylor
2005-08-05 12:52 ` DervishD
2005-08-05 14:01 ` Meino Christian Cramer
2005-08-05 14:29 ` Mikael Magnusson
Code repositories for project(s) associated with this public inbox
https://git.vuxu.org/mirror/zsh/
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).