Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I get the source code for the linux utility tail?

this command is really very useful but where I can get the source code to see what is going on inside .

thanks .

like image 653
Haiyuan Zhang Avatar asked Sep 17 '09 16:09

Haiyuan Zhang


People also ask

How can I view source code in Linux?

If the kernel source code is present in your system, you can find it under the /usr/src/linux-<Version> directory, where <Version> must be replaced with the source code kernel version you are dealing with. You also can find the last kernel source code at https://github.com/torvalds/linux.

What is source code in Linux?

Source code (also referred to as source or code) is the version of software as it is originally written (i.e., typed into a computer) by a human in plain text (i.e., human readable alphanumeric characters).

Is tail a Linux command?

The Linux tail command is an essential tool for the command line. The command is primarily used to output theend of a (text) file or to limit the output of a Linux command. The Linux tail command is thus in line with the Linux head command and “cat” and “less” commands.

How do you tail in Linux?

Tail command also comes with an '+' option which is not present in the head command. With this option tail command prints the data starting from specified line number of the file instead of end. For command: tail +n file_name, data will start printing from line number 'n' till the end of the file specified.


2 Answers

The tail utility is part of the coreutils on linux.

  • Source tarball: ftp://ftp.gnu.org/gnu/coreutils/coreutils-7.4.tar.gz
  • Source file: http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/tail.c

I've always found FreeBSD to have far clearer source code than the gnu utilities. So here's tail.c in the FreeBSD project:

  • http://svnweb.freebsd.org/csrg/usr.bin/tail/tail.c?view=markup
like image 61
Stef Avatar answered Oct 17 '22 04:10

Stef


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.

like image 23
dmckee --- ex-moderator kitten Avatar answered Oct 17 '22 04:10

dmckee --- ex-moderator kitten