zsh-users
 help / color / mirror / code / Atom feed
* List ALL files modified in last 24hrs OR list atleast 10 recent files
@ 2014-03-11 10:25 Amm
  2014-03-12  0:02 ` Ray Andrews
  2014-03-12  6:36 ` Bart Schaefer
  0 siblings, 2 replies; 5+ messages in thread
From: Amm @ 2014-03-11 10:25 UTC (permalink / raw)
  To: zsh-users

Hello,

I am trying to combine two patterns.

1) List plain files modified in last 24hrs (older to newer)

ls -lU *(.mh-24Om) # thats 24, capital oh

This works fine


2) List 10 most recent files (older to newer)

ls -lU *(.Om[-10,-1])

This also works fine.


Now I want to combine (OR) these two such that:

Case 1)
If there are more than 10 files modified in 24hrs
then list them all (not just 10)

Case 2)

If there are, say 7, files modified in last 24hrs
then list those 7 + 3 other most recent files
(listing total 10 most recent files)


I referred to this page:
http://zsh.sourceforge.net/Doc/Release/Expansion.html
(Section 14.8.7 Glob Qualifiers)


I tried:
1) ls -lU *(.mh-24Om[-10,-1])
This (as expected) ANDs the result not OR.


2) ls -lU *(.mh-24,.Om[-10,-1])

Now as per above link:
Comma ORs the pattern so logically first one will pick
files of last 24hrs, next will pick most recent
10 files, both will be ORed (union)


But then in that link there is one line which says:

"Some qualifiers,
however, affect all matches generated,
independent of the sublist in
which they are given.
These are the qualifiers ...and brackets (‘[...]’)"

Which means [-10,-1] is applied at end, effectively
reducing list to 10 files. (even if there are more than
10 files modified in last 24hrs)



I tried several other ways but did not work.

Like:
ls -rlU --sort=time *(.mh-24) *(.Om[-10,-1])


But this causes duplicate entries, plus it fails
if there is nofile modified in last 24hrs.


I want to do it in a single statement not via multiple
commands.


So how do I achieve this? Any idea?

Thanks in advance.

Amm.



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

end of thread, other threads:[~2014-03-12  7:22 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-11 10:25 List ALL files modified in last 24hrs OR list atleast 10 recent files Amm
2014-03-12  0:02 ` Ray Andrews
2014-03-12  7:17   ` Amm
2014-03-12  6:36 ` Bart Schaefer
2014-03-12  7:13   ` Amm

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