[Thread Prev][Thread Next][Index]

Re: [ferret_users] constructing output file names with zero-filled current date string



Hi Ryo,

 It is the exact what I was looking for:

   let cDate = spawn("date --date='($current_date)' +'%d–%b–%y'")

   define sym cdate `cDate`

    !-> define sym cdate 03–Apr–18
    

Thanks a lot for the solution!

--- Peng


On Mon, Apr 2, 2018 at 10:48 PM, Ryo Furue <furue@xxxxxxxxxx> wrote:
Hi Peng,

I need to extract the current date and use it in my output file name. How do I convert:

 

    current_date =” 2-Apr-18”

 

to a fix length, zero-filled date string: cDate=“02-Apr-18”?  


let a = SPAWN("gdate --date='2-Apr-18' +'%d-%b-%y'")
define symbol cDate `a`

The SPAWN() function runs the shell command and gets its output.  I use the command "gdate" above for the GNU version of the "date" command.  On Linux, use "date".  To check if it's the right date command, look at "date --version".

Ryo



--

Ge Peng, PhD
Research Scholar
Cooperative Institute for Climate and Satellites - NC (CICS-NC)/NCSU at

NOAA’s National Centers for Environmental Information (NCEI)

Center for Weather and Climate (CWC)

151 Patton Ave, Asheville, NC 28801
+1 828 257 3009; ge.peng@xxxxxxxx

ORCID: http://orcid.org/0000-0002-1986-9115

Following CICS-NC on Facebook




[Thread Prev][Thread Next][Index]
Contact Us
Dept of Commerce / NOAA / OAR / PMEL / Ferret

Privacy Policy | Disclaimer | Accessibility Statement