How to know the current quarter with date?

前端 未结 2 1724
有刺的猬
有刺的猬 2021-01-28 00:28

Is it possible to know the current quarter using Linux command line?

I didn\'t find a way to do it within the date man page.

2条回答
  •  孤独总比滥情好
    2021-01-28 01:20

    There is now the %q format to show this information.

    From the coreutils-8.26 release log from November 30, 2016:

    New Features
    ...
    date now accepts the %q format to output the quarter of the year.

    And yes it works!

    $ date "+%q"
    4
    $ date "+%Y%q"
    20164
    

提交回复
热议问题