close

Step 1:

vi .bashrc

write the code as below:

# calculate diference between two days
daydiff() {
    d1=$(date -d "$1" +%s)
    d2=$(date -d "$2" +%s)
    echo $(( (d1 - d2) / 86400 )) days
}

Example:

Step 2: type in " daydiff today '3 Dec' ". It will calculate the difference of days between today and Dec 3th.

arrow
arrow
    文章標籤
    linux
    全站熱搜
    創作者介紹
    創作者 ytl0821 的頭像
    ytl0821

    YT Lee's simple notes

    ytl0821 發表在 痞客邦 留言(0) 人氣()