gpt4 book ai didi

bash - 如何在 Bash 中通过 inode 获取文件内容?

转载 作者:行者123 更新时间:2023-11-29 09:07:06 25 4
gpt4 key购买 nike

如何在 Bash 中仅知道文件的 inode 来检索文件内容?

最佳答案

根据 this unixexchange answer :

You cannot access files by inodes, because that would break access control via permissions. For example, if you don't have the permission to traverse a directory, then you can't access any of the files in that directory no matter what the permissions on the file are. If you could access a file by inode, that would bypass directory permissions.

虽然有一些方法可以通过 inode 编号获取文件的路径或名称,例如使用 find .获得文件的路径后,您可以使用任何常规工具。

find 有一个 inum 参数来通过 inode 查找文件。这是一个例子:

find -inum 1704744 -exec cat {} \;

这将打印 inode 1704744 文件的内容,假设它位于当前目录或其子目录之一。

注意:ls 还有一个-i 选项来获取与文件关联的 inode 。

关于bash - 如何在 Bash 中通过 inode 获取文件内容?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/43165762/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com