zsh-users
 help / color / mirror / code / Atom feed
* ls most recent files in a hierarchy
@ 2006-03-16  0:37 zzapper
  2006-03-16  1:46 ` Christian Schneider
  0 siblings, 1 reply; 6+ messages in thread
From: zzapper @ 2006-03-16  0:37 UTC (permalink / raw)
  To: zsh-users

I should know this but i'm tired

1) list all the files in a hierarchy modified in last x days

2) list x most recent files in each directory of a hierarchy

3) list x most recent files in a hierarchy

-- 
http://successtheory.com/ 100 FREE Success and Self-Improvement Tips


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ls most recent files in a hierarchy
  2006-03-16  0:37 ls most recent files in a hierarchy zzapper
@ 2006-03-16  1:46 ` Christian Schneider
  2006-03-16  2:10   ` Lloyd Zusman
  2006-03-16  3:57   ` Bart Schaefer
  0 siblings, 2 replies; 6+ messages in thread
From: Christian Schneider @ 2006-03-16  1:46 UTC (permalink / raw)
  To: zsh-users

* zzapper <david@tvis.co.uk> typed:
> I should know this but i'm tired
> 
> 1) list all the files in a hierarchy modified in last x days

ls -tld **/*(m-2) # modified in the last 2 days

> 2) list x most recent files in each directory of a hierarchy

ls **/*(D.om[1,5]) # 5 recent files

> 3) list x most recent files in a hierarchy

ls *(D.om[1,5])
-- 
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] 6+ messages in thread

* Re: ls most recent files in a hierarchy
  2006-03-16  1:46 ` Christian Schneider
@ 2006-03-16  2:10   ` Lloyd Zusman
  2006-03-16  3:57   ` Bart Schaefer
  1 sibling, 0 replies; 6+ messages in thread
From: Lloyd Zusman @ 2006-03-16  2:10 UTC (permalink / raw)
  To: zsh-users; +Cc: zsh-workers

Christian Schneider <strcat@gmx.net> writes:

> * zzapper <david@tvis.co.uk> typed:
>> 
>> [ ... ]
>
>> 2) list x most recent files in each directory of a hierarchy
>
> ls **/*(D.om[1,5]) # 5 recent files

Hmm ... this one seems to list the five most recent files among all the
files in all the directories.  How would we get the 5 most recent files
in _each_ directory of the hierarchy?  In other words, if, for example,
there were 13 directories in the hierarchy, and if each one contained
more than five files, the desired result would contain 65 file names.


-- 
 Lloyd Zusman
 ljz@asfast.com
 God bless you.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ls most recent files in a hierarchy
  2006-03-16  1:46 ` Christian Schneider
  2006-03-16  2:10   ` Lloyd Zusman
@ 2006-03-16  3:57   ` Bart Schaefer
  2006-03-16 12:31     ` zzapper
  2006-03-18  0:38     ` Christian Schneider
  1 sibling, 2 replies; 6+ messages in thread
From: Bart Schaefer @ 2006-03-16  3:57 UTC (permalink / raw)
  To: zsh-users

On Mar 16,  2:46am, Christian Schneider wrote:
} Subject: Re: ls most recent files in a hierarchy
}
} > 2) list x most recent files in each directory of a hierarchy
} 
} ls **/*(D.om[1,5]) # 5 recent files

As Lloyd has pointed out, that's actually the answer to #3:

} > 3) list x most recent files in a hierarchy

The answer to #2 is less obvious:

  ls *(ND.om[1,5]) **/*(D/e:'reply=( $REPLY/*(ND.om[1,5]) )':)

That also requires a fairly recent version of zsh; none of the 4.2.x
series has the fix, they'll either crash or go into an infinite loop
when presented with the glob-within-a-glob.

For the 4.2.x line, you need something like:

  dirs=( '' **/*(DM/) ) eval 'ls ${^dirs}*(ND.om[1,5])'

which is perhaps clearer anyway and works in 4.3.x too.


^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ls most recent files in a hierarchy
  2006-03-16  3:57   ` Bart Schaefer
@ 2006-03-16 12:31     ` zzapper
  2006-03-18  0:38     ` Christian Schneider
  1 sibling, 0 replies; 6+ messages in thread
From: zzapper @ 2006-03-16 12:31 UTC (permalink / raw)
  To: zsh-users

Thanks Zedites

The following is most useful for solving the "What was the name of the file 
I created/modified recently somewhere in this hierarchy" problem

# list 5 most recent files in hierarchy
ls -lt **/*.tex(D.om[1,5]) 


# variation with paging

ls -lt **/*.tex(D.om) | more




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: ls most recent files in a hierarchy
  2006-03-16  3:57   ` Bart Schaefer
  2006-03-16 12:31     ` zzapper
@ 2006-03-18  0:38     ` Christian Schneider
  1 sibling, 0 replies; 6+ messages in thread
From: Christian Schneider @ 2006-03-18  0:38 UTC (permalink / raw)
  To: zsh-users

Hi,

* Bart Schaefer <schaefer@brasslantern.com> typed:
> On Mar 16,  2:46am, Christian Schneider wrote:
> } Subject: Re: ls most recent files in a hierarchy
> }
> } > 2) list x most recent files in each directory of a hierarchy
> } 
> } ls **/*(D.om[1,5]) # 5 recent files
> 
> As Lloyd has pointed out, that's actually the answer to #3:

Thats correct. I get it wrong. Sorry about that.

> } > 3) list x most recent files in a hierarchy
> 
> The answer to #2 is less obvious:
> 
>   ls *(ND.om[1,5]) **/*(D/e:'reply=( $REPLY/*(ND.om[1,5]) )':)
> 
> That also requires a fairly recent version of zsh; none of the 4.2.x
> series has the fix, they'll either crash or go into an infinite loop
> when presented with the glob-within-a-glob.
> 
> For the 4.2.x line, you need something like:
> 
>   dirs=( '' **/*(DM/) ) eval 'ls ${^dirs}*(ND.om[1,5])'
> 
> which is perhaps clearer anyway and works in 4.3.x too.

Thanks! I can can dispose it on a old^Wstable Debian i also managed.
-- 
Could I have a drug overdose?


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2006-03-18  0:38 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-03-16  0:37 ls most recent files in a hierarchy zzapper
2006-03-16  1:46 ` Christian Schneider
2006-03-16  2:10   ` Lloyd Zusman
2006-03-16  3:57   ` Bart Schaefer
2006-03-16 12:31     ` zzapper
2006-03-18  0:38     ` Christian Schneider

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).