sto*_*eff 29
是的,参数 -i 将打印 ls 命令列出的每个文件或目录的 inode 编号。由于您想打印目录的 inode 编号,我建议使用参数 -d 仅列出目录。要在目录 /path/to/dir 中打印 inode 编号,请使用以下命令行:
ls -id /path/to/dir
Run Code Online (Sandbox Code Playgroud)
来自man ls
:
-d, --directory
list directory entries instead of contents, and do not derefer?
ence symbolic links
-i, --inode
print the index number of each file
Run Code Online (Sandbox Code Playgroud)
小智 19
这也适用于 stat:
DIR=/
stat -c '%i' $DIR
Run Code Online (Sandbox Code Playgroud)
来自man stat
:
-c --format=FORMAT
use the specified FORMAT instead of the default; output a new?
line after each use of FORMAT
[...]
The valid format sequences for files:
%i inode number
Run Code Online (Sandbox Code Playgroud)