bash

I tried using $(date) in my bash shell script, however I want the date in YYYY-MM-DD format. How do I get this?


In Bash:

get year-month-day from date

DATE=`date +%Y-%m-%d`

get year-month-day hour:minute:second from date

DATE=`date '+%Y-%m-%d %H:%M:%S'`

Other available date formats can be viewed from the date man pages:

man date

试试: $(date +%F)


你可以做这样的事情:

$ date +'%Y-%m-%d'
链接地址: http://www.djcxy.com/p/4350.html

上一篇: 循环浏览Bash中的文件内容

下一篇: 庆典