head - output the first part of files


Usage

head [OPTION]... [FILE]...

Print first 10 lines (by default) of each FILE to standard output. With more than one FILE, precede each with a header giving the file name.

linux3[296]% ls
maze.c  maze.h  proj3.c
linux3[297]% head proj3.c
/*          File:  proj3.c
 *        Author:  Daniel J. Hood
 *          Date:  March 29, 1999
 * Last Modified:  April 5, 1999
 *   Description:  This program simulates a dynamic maze.  A mouse starts in
 *                 the middle square of the maze and attempts to escape the
 *                 maze by moving off any edge.  This file contains main() and
 *                 is the primary file for the project.  This file makes calls
 *                 to the functions in maze.c
 */
linux3[298]%

Or with several files:

linux3[300]% head proj3.c maze.c maze.h
==> proj3.c <==
/*          File:  proj3.c
 *        Author:  Daniel J. Hood
 *          Date:  March 29, 1999
 * Last Modified:  April 5, 1999
 *   Description:  This program simulates a dynamic maze.  A mouse starts in
 *                 the middle square of the maze and attempts to escape the
 *                 maze by moving off any edge.  This file contains main() and
 *                 is the primary file for the project.  This file makes calls
 *                 to the functions in maze.c
 */

==> maze.c <==
/*          File: maze.c
 *        Author: Daniel J. Hood
 *          Date: March 30, 1999
 * Last Modified: April 5, 1999
 *   Description: This file contains definitions for all of the functions used
 *                in proj3.c
 */

#include <stdio.h>
#include <stdlib.h>

==> maze.h <==
/*          File: maze.h
 *        Author: Daniel J. Hood
 *          Date: March 30, 1999
 * Last Modified: April 12, 1999
 *   Description: This file contains the function prototypes that are called
 *                from within proj3.c  It also contains the #defines that
 *                are used from within BOTH proj3.c AND maze.c
 */


linux3[308]%

-n NUMBER

Print first NUMBER lines instead of default first 10.

linux3[311]% head -n 4 proj3.c
/*          File:  proj3.c
 *        Author:  Daniel J. Hood
 *          Date:  March 29, 1999
 * Last Modified:  April 5, 1999
linux3[312]%

Daniel J. Hood
Last modified: Thu Sep 30 14:24:28 EDT 2004