LoginSignup
4
3

More than 5 years have passed since last update.

(bash) dateで指定した日付を表示する

Posted at

1日前、1ヶ月後等の日付を表示する。
フォーマットと併用すると、結構使う機会多い。

要約

BSD date

Macの標準はこっち。

# 1日先
date -v+1d
# 1ヶ月前
date -v-1m

GNU date

Linuxの標準はこっち

# 1日先
date --date '1 days'
# 1ヶ月前
date --date '1 month ago'

説明

dateはBSDかGNUで使い方が大きく異なるので注意。
date --version でバージョンが出るのはGNU
出ないのはBSD

もしくは、man date をすればBSDかGNUか判明する。

4
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
4
3