You might find it an interesting exercise to write your own. The vast majority of the Unix command-line tools are a page or so of fairly straightforward C code.
To just look at the code, the GNU CoreUtils sources are easily found on gnu.org or your favorite Linux mirror site.
You might find it an interesting exercise to write your own. The vast majority of the Unix command-line tools are a page or so of fairly straightforward C code.
To just look at the code, the GNU CoreUtils sources are easily found on gnu.org or your favorite Linux mirror site.
Poke around the uclinux site. Since they distributed the software, they are required to make the source available one way or another.
Or, you could read
man fseek
and guess at how it might be done.NB-- See William's comments below, there are cases when you can't use seek.
The tail utility is part of the coreutils on linux.
I've always found FreeBSD to have far clearer source code than the gnu utilities. So here's tail.c in the FreeBSD project: