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?
Answer: To find a file by its inode number, you can use the argument -inum with the find command. e.g.
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.
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.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With