On 2009-11-30, Aarto Matti wrote:
> Hi,
> 
> I need to set the output from the following command to a variable:
> date +%s
> It's a string of 10 digits.
> 
> I tried
> let stamp = execute "!date +\%s"
> but apparently "execute" doesn't return anything, besides I can't escape "%"
> character which is treated as buffer name.

As sc wrote, strftime() is a better solution in this case.  However,
for commands for which Vim does not have an internal equivalent, use
system(), e.g.,

    let stamp = system("date +%s")

That will include the trailing newline in your stamp variable.  If
that's undesirable, use this instead:

    let stamp = substitute(system("date +%s"), '\n', '', '')

HTH,
Gary


-- 
You received this message from the "vim_use" maillist.
For more information, visit http://www.vim.org/maillist.php

Reply via email to