Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Copy newest file to newest directory
- X-seq: zsh-users 11068
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Copy newest file to newest directory
- Date: Fri, 08 Dec 2006 13:22:38 +0100
- In-reply-to: <Xns98937B980EE3Ezzappergmailcom@xxxxxxxxxxx>
- Mail-followup-to: zsh-users@xxxxxxxxxx
- Mailing-list: contact zsh-users-help@xxxxxxxxxx; run by ezmlm
- Operating-system: Linux 2.6.19-rc6-git11suspend2+ipw2200 i686
- References: <Xns98937B980EE3Ezzappergmailcom@xxxxxxxxxxx>
zzapper <david@xxxxxxxxxx>:
> I have some global aliases which call scripts such that I can write
>
> > cp NF ND
> Where NF copies the newest file to ND the newest directory
> these are relative to current directory
>
> I'd like to be able to generalise this ie
>
> > cp /tmp/NF /store/ND
>
> Obviously the above cannot work but any (lateral) ideas?
How about something like this:
[snip]
function cpn() {
local nf nd
nf=${1}/*(.om[1]N)
nd=${2}/*(/om[1]N)
[[ -n ${nd} && -n ${nf} ]] && command cp ${nf} ${nd}
}
[snap]
% cpn /tmp /store
Regards, Frank
--
In protocol design, perfection has been reached not when there is
nothing left to add, but when there is nothing left to take away.
-- RFC 1925
Messages sorted by:
Reverse Date,
Date,
Thread,
Author