How can i format the date "01-SEP-2011" on "2011-09-01" format in shell script?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
Try this:
$ date --date='01-SEP-2011' +%Y-%m-%d
回答2:
If you have Ruby installed on the target system you could do this:
#/bin/bash
read DATE # 01-SEP-2011
set DATE=$(ruby -rdate -e "puts Date.parse('$DATE').to_s")
echo $DATE # 2011-09-01
回答3:
kent$ date +%F -d "01-SEP-2011"
2011-09-01