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

Re: script to return most recent file in a remote directory



On Tue, Feb 10, 2009 at 16:43, zzapper <david@xxxxxxxxxx> wrote:

> Somebody wrote me a script to copy the newest file in a distant directory to
> the current directory, unfortunately I can't find it, (it was at least a year
> ago)

Do you mean the following?

Frank Terbeck <ft@xxxxxxxxxxxxxxxxxx> wrote in
news:20061208134715.GC17120@xxxxxxxxxxxxxxx:

Frank
Thanks I've just added an echo

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)
 result="cp $nf $nd"
 [[ -n ${nd} && -n ${nf} ]] && command cp ${nf} ${nd} ; echo $result
}



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