Zsh Mailing List Archive
Messages sorted by:
Reverse Date,
Date,
Thread,
Author
Re: Copy newest file to newest directory
- X-seq: zsh-users 11070
- From: Frank Terbeck <ft@xxxxxxxxxxxxxxxxxx>
- To: zsh-users@xxxxxxxxxx
- Subject: Re: Copy newest file to newest directory
- Date: Fri, 08 Dec 2006 14:47:15 +0100
- In-reply-to: <Xns98938890B9A97zzappergmailcom@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> <20061208122238.GA17120@xxxxxxxxxxxxxxx> <Xns98938890B9A97zzappergmailcom@xxxxxxxxxxx>
[zzapper: sorry, 1st mail went to you in private.]
zzapper <david@xxxxxxxxxx>:
> Frank Terbeck <ft@xxxxxxxxxxxxxxxxxx>:
>
> > 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
> >
> > [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
>
> Frank,
> Looks the business, but not does not work for me
Yeah, that's what happens, if you don't try out what you've posted. :-)
[snip]
function cpn() {
setopt localoptions
setopt globassign
local nf nd
[[ -z ${1} || -z ${2} ]] && printf 'usage: cpn <fromdir> <todir>\n' && return 1
nf=${1}/*(.om[1]N)
nd=${2}/*(/om[1]N)
[[ -n ${nd} && -n ${nf} ]] && command cp ${nf} ${nd}
}
[snap]
That should work better.
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