Parse Date in Bash

前端 未结 10 1654
灰色年华
灰色年华 2020-11-29 02:17

How would you parse a date in bash, with separate fields (years, months, days, hours, minutes, seconds) into different variables?

The date format is: YYYY-MM-D

10条回答
  •  北海茫月
    2020-11-29 02:54

    instead of using the shell scripting,incorporate in your scripting itself like below wheever you need:

    a=date +%Y 
    b=date +%S
    c=date +%H
    

    a will be year b will be seconds c will be hours. and so on.

提交回复
热议问题