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 Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s