Rok Dolinar Rok Dolinar - 1 year ago 67
Linux Question

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

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 Source

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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download