date命令不遵循Linux的规格(Mac OS X的狮子) [英] Date command does not follow Linux specifications (Mac OS X Lion)

查看:1303
本文介绍了date命令不遵循Linux的规格(Mac OS X的狮子)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在开发我的Linux系统中的脚本很长一段时间,并希望我的Mac上运行它。

I have been developing a script on my linux box for quite some time, and wanted to run it on my Mac as well.

我认为Mac上的功能是相同的Linux上的功能,但现在我意识到这是错误的。我知道,在Mac上存在较少的功能,但我想,即这功能的存在,有相同的实现。

I thought that the functions on the Mac were the same as the functions on linux, but today I realized it was wrong. I knew that fewer functions existed on the Mac, but I thought that the functions that did exist, had the same implementation.

此问题是专门在问候了日期命令。

This problem is specifically in regards to the date command.

当我在我的Linux机器上运行命令的参数来提供纳秒一段时间,我得到正确的结果,但是当我在我的Mac上运行它,它没有这样的选择。

When I run the command on my linux machine with the parameter to provide some time in nanoseconds, I get the correct result, but when I run it on my mac, it does not have that option.

Linux-Machine> date +%N
55555555555 #Current time in nanoseconds
Mac-Machine> date +%N
N

我如何去获得当前时间在纳秒的Mac吗?

How do I go about getting the current time in nanoseconds as a bash command on the Mac?

最坏的情况是,我创建了一小块code的,在C或东西调用系统函数,然后我的脚本中调用它。

Worst case is I create a small piece of code that calls a system function in C or something and then call it within my script.

任何帮助很多AP preciated!

Any help is much appreciated!

推荐答案

这是因为OSX和Linux使用两套不同的工具。 Linux使用日期命令(因此,GNU / Linux)的GNU版本。请记住,Linux是Linux和OS X是Unix的。他们是不同的。

This is because OSX and Linux use two different sets of tools. Linux uses the GNU version of the date command (hence, GNU/Linux). Remember that Linux is Linux and OS X is Unix. They're different.

您可以安装GNU 日期包括在从的 MacPorts的。它会在系统上安装为 gdate 。您可以使用,或链接日期二进制与新的 gdate 二进制;你的选择。

You can install the GNU date command which is included in the "coreutils" package from MacPorts. It will be installed on your system as gdate. You can either use that, or link the date binary with the new gdate binary; your choice.

这篇关于date命令不遵循Linux的规格(Mac OS X的狮子)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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