I have something in Python which saves a file in the following datetime format:
>>> s = time.strftime('%Y%m%d%H%M%S')
>>> print s
20121208145544
Things have changed slightly and this now needs to be done in shell. Is there a way to get the datetime in exactly the same format using shell?
Something like
touch filename_`/bin/date +%Y%m%d%H%M%S`.txt
creates an empty file
filename_20130104112845.txt
使用date
命令 ,它采用完全相同的格式参数,并带有+
:
date +%Y%m%d%H%M%S
This works too:
>>> z = time.strftime('%Y%m%d%H%M%S')
>>> file_ = open(z+'.txt', 'w')
>>> file_.close()
This creates 20130104160557.txt.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.