How can i format the date "01-SEP-2011" on "2011-09-01" format in shell开发者_如何学C script?
Try this:
$ date --date='01-SEP-2011' +%Y-%m-%d
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
kent$ date +%F -d "01-SEP-2011"
2011-09-01
精彩评论