From: Amm <ammdispose-zsh@yahoo.com>
To: "zsh-users@zsh.org" <zsh-users@zsh.org>
Subject: Re: List ALL files modified in last 24hrs OR list atleast 10 recent files
Date: Wed, 12 Mar 2014 15:13:47 +0800 (SGT) [thread overview]
Message-ID: <1394608427.25019.YahooMailNeo@web194606.mail.sg3.yahoo.com> (raw)
In-Reply-To: <140311233656.ZM12220@torch.brasslantern.com>
On Mar 12, 12:06 PM Bart Schaefer wrote:
}} 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.
} You can avoid the failure by adding an N to each of the glob qualifiers:
} ls -rlU --sort=time *(N.mh-24) *(N.Om[-10,-1])
Great I did not know about N flag. That solved one problem.
} Combining the -U (unsorted) and --sort=time options doesn't sense here?
Yep, -U was typing mistake for that example.
} Your original statement of the problem implies you want the files from
} the last 24 hours sorted by name followed by any other recent files
} sorted by time.
No everything sorted by time.
} To remove the duplicates, you can assign the results to an array, then
} expand only the uniqe elements with ${(u)array}. In recent versions of
} zsh you can do this with an anonymous function:
} (){ ls -lU "${(u)@}" } *(N.mh-24Om) *(N.Om[-10,-1])
Actually today I was trying typeset like this.
lst() {
typeset -U plst
plst=(*(.Om[-10,-1]))
plst=($plst *(.mh-24))
ls -lr --sort=time $plst
}
But now I can combine your two suggestions of N and (u)
plus anonymous function to make it a single command.
lst () {
() {
ls -lr --sort=time "${(u)@}"
} *(N.mh-${1:-24}) *(N.Om[-${2:-10},-1])
}
Note: I have extended it so that I can pass parameters to
function. i.e. lst [hours] [nooflines]
Works perfect as per my requirement.
Thanks a lot for your solution.
Amm.
prev parent reply other threads:[~2014-03-12 7:19 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2014-03-11 10:25 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 [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1394608427.25019.YahooMailNeo@web194606.mail.sg3.yahoo.com \
--to=ammdispose-zsh@yahoo.com \
--cc=zsh-users@zsh.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).