本文介绍了找不到选项-printf,现在怎么办?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我没有找到为什么Mac的find没有选项-printf的原因。
苹果通常决定选择与其他命令不正交的选项吗?

如何达到与以下命令相同的结果Mac 没有coreutils?

  find。 -printf%i \\\
//在Ubuntu中命令


解决方案

这并不是苹果公司取消选项,而是OS X的UNIX基础大部分是从FreeBSD衍生出来的,其中许多部分可以追溯到原来的UNIX ...而不是GNU工具,添加了许多功能。



在这种情况下,不支持 -printf ,所以我不希望OS X也是。相反,这应该在BSD-ish系统上工作:

  find。 -print0 | xargs -0 stat -f'%i'

GNU用户空间系统会失败, (1) xargs -0 -r stat -c'%i'因为 xargs(1)和 stat(1)行为是不同的。


I have not found a reason why Mac's find does not have the option -printf.Apple normally decides to take options out which are not orthogonal to the other commands?

How can you reach the same result as the following command in Mac without coreutils?

find . -printf "%i \n"         // command in Ubuntu
解决方案

It's not that Apple removes options, it's that OS X's UNIX underpinnings are mostly derived (circuitously) from FreeBSD, many parts of which can be traced back to the original UNIX... as opposed to the GNU utilities, which are re-implementations with many features added.

In this case, FreeBSD's find(1) doesn't support -printf, so I wouldn't expect OS X's to either. Instead, this should work on a BSD-ish system:

find . -print0 | xargs -0 stat -f '%i '

It'll fail on a GNU-userland system, though, where you'd write xargs -0 -r stat -c '%i ' because xargs(1) and stat(1) behavior is different.

这篇关于找不到选项-printf,现在怎么办?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-31 11:29