热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

如何在Linux中仅提取文件的inode编号?-HowcanIextractonlyaninodenumberforafileinLinux?

justaquickquestion.Iwanttousemyinodenumberinmybashscripthowever,Ineedsomehelp.只是

just a quick question. I want to use my inode number in my bash script however, I need some help.

只是一个简单的问题。我想在我的bash脚本中使用我的inode编号,但是,我需要一些帮助。

I'm using command ls -i "filename", which echoes "inode number" "filename". The problem is, I only need inode number. Is there a way, where i can "slice" the output?

我正在使用命令ls -i“filename”,它回显“inode number”“filename”。问题是,我只需要inode号码。有没有办法,我可以“切片”输出?

2 个解决方案

#1


5  

You can use stat command with %i to get only inode nuymbers:

您可以使用带有%i的stat命令来仅获取inode nuymbers:

stat -c '%i' *

Most of the utilities/commands use to get inode use lstat system call which is the one used by stat command too.

大多数实用程序/命令用于获取inode使用lstat系统调用,这也是stat命令使用的系统调用。

#2


1  

you can also awk over the ls

你也可以轻击过ls

    -bash-3.2$ ls -i current.py | awk '{print $1}'

推荐阅读
author-avatar
0鞋包控0
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有