Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: List ALL files modified in last 24hrs OR list atleast 10 recent files
- X-seq: zsh-users 18589
- From: Amm <ammdispose-zsh@xxxxxxxxx>
- To: "zsh-users@xxxxxxx" <zsh-users@xxxxxxx>
- 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)
- Dkim-signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=yahoo.com; s=s1024; t=1394608427; bh=ZionLwq7FyYUQ1Q7oWcCBaOsp+GQyZqF8AGbk/nA4Qo=; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=fb6ZMHV1/FNuTlFcCdZeliXno0lzEwAm5Sc/ILw8KtXPbTpE1zF8SRn4KHiWs8Sgknm9MKQjboQ+x6c9sIQEnZSDQCr2Sw6bq5NmvAXWaYqm3HG3ypOJZKQ2GBPvQmxQSCSnQKnQsnBE/WiB7OAa7xdilgviWneiNtzn5XvBP/s=
- Domainkey-signature: a=rsa-sha1; q=dns; c=nofws; s=s1024; d=yahoo.com; h=X-YMail-OSG:Received:X-Rocket-MIMEInfo:X-Mailer:References:Message-ID:Date:From:Reply-To:Subject:To:In-Reply-To:MIME-Version:Content-Type:Content-Transfer-Encoding; b=d1MAaW5J4DIfQHpHYa3Zk3o0vgULFGk2rTFFWs2/T+vossdwNHctj3rVpQVHHV3LTklAaw8DsegcsRfpAnl6qNWXGLzBhR4ATiE6vzMitrAW4cA96AD+bb2djJKk17w9IFMKiiMXzqcifZZrVHTNUcpzU9UprsnUl0FU8FCZ3AQ=;
- In-reply-to: <140311233656.ZM12220@torch.brasslantern.com>
- List-help: <mailto:zsh-users-help@zsh.org>
- List-id: Zsh Users List <zsh-users.zsh.org>
- List-post: <mailto:zsh-users@zsh.org>
- Mailing-list: contact zsh-users-help@xxxxxxx; run by ezmlm
- References: <1394533556.43856.YahooMailNeo@web194603.mail.sg3.yahoo.com> <140311233656.ZM12220@torch.brasslantern.com>
- Reply-to: Amm <ammdispose-zsh@xxxxxxxxx>
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.
Messages sorted by:
Reverse Date,
Date,
Thread,
Author