In Linux/Unix/GNU based system, "head <file-name>" command will print the first 10 lines of each file.
With more than one FILE, precede each with a header giving the file name.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options too.
-c, --bytes=[-]N print the first N bytes of each file;
with the leading `-', print all but the last
N bytes of each file
-n, --lines=[-]N print the first N lines instead of the first 10;
with the leading `-', print all but the last
N lines of each file
-q, --quiet, --silent never print headers giving file names
-v, --verbose always print headers giving file names
--help display this help and exit
--version output version information and exit
N may have a multiplier suffix: b 512, k 1024, m 1024*1024.
Linux# head myfile1
myfile1-example-line1
myfile1-example-line2
myfile1-example-line3
myfile1-example-line4
myfile1-example-line5
myfile1-example-line6
myfile1-example-line7
myfile1-example-line8
myfile1-example-line9
myfile1-example-line10
Linux#
!! Multiple files example !!
Linux# head myfile1 myfile2
==> myfile1 <==
myfile1-example-line1
myfile1-example-line2
myfile1-example-line3
myfile1-example-line4
myfile1-example-line5
myfile1-example-line6
myfile1-example-line7
myfile1-example-line8
myfile1-example-line9
myfile1-example-line10
==> myfile2 <==
myfile2-example-line1
myfile2-example-line2
myfile2-example-line3
myfile2-example-line4
myfile2-example-line5
myfile2-example-line6
myfile2-example-line7
myfile2-example-line8
myfile2-example-line9
myfile2-example-line10
Linux#
Syntax:
head <file-name>Usage:
head [OPTION]... [FILE]...With more than one FILE, precede each with a header giving the file name.
With no FILE, or when FILE is -, read standard input.
Mandatory arguments to long options are mandatory for short options too.
-c, --bytes=[-]N print the first N bytes of each file;
with the leading `-', print all but the last
N bytes of each file
-n, --lines=[-]N print the first N lines instead of the first 10;
with the leading `-', print all but the last
N lines of each file
-q, --quiet, --silent never print headers giving file names
-v, --verbose always print headers giving file names
--help display this help and exit
--version output version information and exit
N may have a multiplier suffix: b 512, k 1024, m 1024*1024.
Example:
!! One file example !!Linux# head myfile1
myfile1-example-line1
myfile1-example-line2
myfile1-example-line3
myfile1-example-line4
myfile1-example-line5
myfile1-example-line6
myfile1-example-line7
myfile1-example-line8
myfile1-example-line9
myfile1-example-line10
Linux#
!! Multiple files example !!
Linux# head myfile1 myfile2
==> myfile1 <==
myfile1-example-line1
myfile1-example-line2
myfile1-example-line3
myfile1-example-line4
myfile1-example-line5
myfile1-example-line6
myfile1-example-line7
myfile1-example-line8
myfile1-example-line9
myfile1-example-line10
==> myfile2 <==
myfile2-example-line1
myfile2-example-line2
myfile2-example-line3
myfile2-example-line4
myfile2-example-line5
myfile2-example-line6
myfile2-example-line7
myfile2-example-line8
myfile2-example-line9
myfile2-example-line10
Linux#
Linux/Unix - Print The First 10 Lines of Each File
Reviewed by Admin
on
07:04:00
Rating:
![Linux/Unix - Print The First 10 Lines of Each File](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEg2KdvqUfPZ9e_tDFUNpgpCaMewcWc9mlavavMXDncoMT0YCt30J0m7VWyDNJ3QYwLAGaGeY2hdEn4wZ7gCvUA1GjcDn6l4ipqYfDEeLARWOObKBSG_VvqvCD7hCF-4hm9meOUxViVyPqel/s72-c/logo_linux_square.jpg)