Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

List ALL files modified in last 24hrs OR list atleast 10 recent files



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.




Messages sorted by: Reverse Date, Date, Thread, Author