Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I extract only an inode number for a file in Linux?

Tags:

linux

bash

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

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?

like image 695
Rok Dolinar Avatar asked Apr 13 '15 15:04

Rok Dolinar


People also ask

How can you find a file using only its inode number?

Answer: To find a file by its inode number, you can use the argument -inum with the find command. e.g.

Which command is used to print the inode number for each file?

An inode number stores all the information about a regular file, directory, or other file system object, except its data and name. To find an inode, either use the ls or stat command.

How can an inode file be retrieved?

DESCRIPTION top. Each file has an inode containing metadata about the file. An application can retrieve this metadata using stat(2) (or related calls), which returns a stat structure, or statx(2), which returns a statx structure.


1 Answers

You can use stat command with %i to get only 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.

like image 124
P.P Avatar answered Oct 27 '22 01:10

P.P