stat
system call. I've
written a program, distance.c
,
that you can use to find this difference for any file.
To find these inode distances for all the normal files under
/tmp/lib
, sorted into numerical order, you could use
the following command
find /tmp/lib -type f -exec ./distance '{}' ';' | sort -n >/tmp/filedistsYou can find the range of distances by looking at the first and last line of the file, with the commands
head -1 /tmp/filedists tail -1 /tmp/filedistsYou might also be interested in the median value, which you can find by using
wc -l /tmp/filediststo count the number of lines and then a combination of
head
piped into tail
to select out the
middle line. (Use head
to select out the first half of
the file, rather than just the first line, and then use
tail
to select out the last line of that first half.)
You can find the range and median of the inode distances for
directories similarly, but using d
rather than
f
for the -type
option to the
find
command.
Instructor: Max Hailperin