How to format the date in KornShell script to DD-MON-YYYY?

ε祈祈猫儿з 提交于 2019-12-01 19:16:05

This is what finally worked on unix(solaris).

date '+%d-%h-%Y' | tr [:lower:] [:upper:]

returned: 04-NOV-2009

Mark Rushakoff

The ^ character forces uppercase in the GNU coreutils date (at least, it does in version 6.9.92.4 of coreutils):

$ date '+%d-%^h-%Y'
04-NOV-2009

Unfortunately, ^ is not POSIX standard for date, so you'll probably have to resort to a second command such as the tr suggested by @martin clayton, if you aren't on a GNU system.

You could uppercase it yourself if caret uppercase is not supported in your environment:

date '+%d-%h-%Y' | tr 'a-z' 'A-Z'
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!