head – output the first part of files

commandline session

$cat bash.txt
hack
hacker
$head bash.txt
hack
hacker
$head -n 1 bash.txt
hack
$head -n 2 bash.txt
hack
hacker
$head -n 3 bash.txt
hack
hacker
$head -v -n 1 bash.txt
==> bash.txt  bash.txt <==
hack
hacker
$

http://www.gnu.org/software/coreutils/manual/html_node/head-invocation.html

$ head -n 1 qsort.c
#include
$ head -n 2 qsort.c
#include

$ head -n 3 qsort.c
#include

void quick_sort (int *a, int n) {
$ head -n 4 qsort.c
#include

void quick_sort (int *a, int n) {
    if (n  qsort.c <==
#include

void quick_sort (int *a, int n) {
    if (n  source.c <==
 #include 

int
main(int argc, char *argv[])
$ head -n 1 qsort.c source.c
==> qsort.c <==
#include

==> source.c <==
 #include 
$ head -n 1 qsort.c -n 2 source.c
==> qsort.c <==
#include


==> source.c <==
 #include 

$ head -n 1 qsort.c -n 5 source.c
==> qsort.c <==
#include

void quick_sort (int *a, int n) {
    if (n  source.c <==
 #include 

int
main(int argc, char *argv[])
    {
$ head -n 1 qsort.c  source.c
==> qsort.c <==
#include

==> source.c <==
 #include 
$

SOURCE CODE
http://git.savannah.gnu.org/cgit/coreutils.git/tree/src/head.c

Leave a comment

Your email address will not be published. Required fields are marked *