解析日期在巴什 [英] Parse Date in Bash

查看:113
本文介绍了解析日期在巴什的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

你会如何解析在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 /斌/日期二元许多变革:

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.

这篇关于解析日期在巴什的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆