find 缺少选项 -printf,现在怎么办? [英] find lacks the option -printf, now what?

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

问题描述

我还没有找到 Mac 的 find 没有选项 -printf 的原因.Apple 通常决定去掉与其他命令不正交的选项?

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?

在没有 coreutils 的情况下,如何在 Mac 中获得与以下命令相同的结果?

find . -printf "%i 
"         // command in Ubuntu

推荐答案

并不是 Apple 删除了选项,而是 OS X 的 UNIX 基础大部分(迂回地)从 FreeBSD 派生而来,其中许多部分可以追溯到原始UNIX... 与 GNU 实用程序相反,后者是添加了许多功能的重新实现.

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.

在这种情况下,FreeBSD 的 find(1) 不支持 -printf,所以我不希望 OS X 支持.相反,这应该适用于 BSD-ish 系统:

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 '

不过,它会在 GNU 用户系统上失败,您可以在其中编写 xargs -0 -r stat -c '%i ' 因为 xargs(1)stat(1) 行为不同.

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.

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

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