在 Bash 中解析日期 [英] Parse Date in Bash
本文介绍了在 Bash 中解析日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何将 bash 中的日期解析为不同的变量?
How would you parse a date in bash, with separate fields (years, months, days, hours, minutes, seconds) into different variables?
日期格式为:YYYY-MM-DD hh:mm:ss
推荐答案
必须是 bash 吗?您可以使用 GNU coreutils /bin/date
二进制文件进行许多转换:
Does it have to be bash? You can use the GNU coreutils /bin/date
binary for many transformations:
$ date --date="2009-01-02 03:04:05" "+%d %B of %Y at %H:%M and %S seconds"
02 January of 2009 at 03:04 and 05 seconds
这会解析给定的日期并以选定的格式显示它.您可以根据自己的需要随意调整.
This parses the given date and displays it in the chosen format. You can adapt that at will to your needs.
这篇关于在 Bash 中解析日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文