在Mac OS上的date命令 [英] date command on Mac OS

查看:363
本文介绍了在Mac OS上的date命令的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想在Mac上使用date命令来查找对应于某个日期的日期。

I would like to use the date command on a Mac to find out the day corresponding to a certain date.

在Debian上,命令如下:

On Debian the command below works:

date --date "Jul 20 1999" +%A

但是当我使用Mac终端时,同样的命令不起作用。

But the same command does not work when I use Mac's terminal.

在Mac上实现上述命令的输出是什么?

What can be an alternative to achieve the output of the above command on a Mac?

推荐答案

这样做:

date -j -vJulm -v20d -v1999y '+%A'

根据OSX < a href =https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/date.1.html =nofollow>日期手册页::


-v

调整(即取当前日期并显示调整结果;实际上未设定
的日期)根据 val 的秒,分,小时,月日,周,月, em>。如果
val 之前带有加号或减号,则按照
向前或向后调整日期到其余字符串,否则设置日期的相关部分。日期可以是
根据需要使用这些标志调整次数。

-v
Adjust (i.e., take the current date and display the result of the adjustment; not actually set the date) the second, minute, hour, month day, week day, month or year according to val. If val is preceded with a plus or minus sign, the date is adjusted forwards or backwards according to the remaining string, otherwise the relevant part of the date is set. The date can be adjusted as many times as required using these flags.

这篇关于在Mac OS上的date命令的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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