head

output the first part of files
or
supress the end

head [--silent] [--verbose][--lines n] [file][]
     [--quiet]  [-v]        [-n n]
      [
-q]                   [--bytes b]
                          [-c c]

Output the first lines of each file to standard output.
With more than one file, precede each with a header giving the file name.
With no file, or when file is -, read standard input.

[-n ][-]n
--lines=[-]n
output the first n lines, default 10
¬With the leading - output all but the last n lines of each file (like a footing)
(with tail use + to skip the beginning, like a heading)
cat sixlines
1
2
3
4
5
total 15
head -n 2 sixlines
1
2
head -n -1 sixlines # ¬
1
2
3
4
5
n may have a multiplier suffix: blocks 512, k 1024, m 1024*1024.
-c [-]c
--bytes=[-]c
output the first c characters/bytes of each file;
with the leading '-', output all but the last c characters/ bytes of each file
-q
--quiet
--silent
never output headers giving file names
-v
--verbose
always output headers
--help
--version

tail

output the last part of files or supress the beginning

tail [--silent] [--verbose][--lines n] [file][]
     [--quiet]  [-v]        [-n n]
      [
-q]                   [--bytes b]
                          [-c c]

Output the last lines of each file to standard output, default 10.
With more than one file, precede each with a header giving the file name.
With no file, or when file is -, read standard input.

[-n] [+]n[sufx]
--lines=[+]n[sufx]
output the last n lines, default 10
Use --lines=+n to output lines starting with the nth , like to skip a heading)

cat sixlines
DAILY
1
2
3
4
5
tail -n2 sixlines
4
5
tail -n +2 sixlines
1
2
3
4
5
-c [+]n[sufx]
--bytes= [+]n[sufx]
output the last n characters / bytes;
use -c +n to output bytes starting with the nth character of each file

sufx multiplier suffix: b 512, kB 1000, K 1024, MB 1000*1000, M 1024*1024,
GB 1000*1000*1000, G 1024*1024*1024, and so on for T, P, E, Z, Y.

-f
--follow[={fd|name}]
output appended data as the file grows, Useful for watching the log file of a running process.
Default: follow the file descriptor, if file is renamed, displaying additions continues.
This is not desirable when tracking the actual name of the file, (for example: log rotation).

--follow=name tracks file even if it is renamed or removaled-and-recreationed.

--pid=pid with -f, terminate after process PID ends.
--retry Keep trying to open file if it is or becomes inaccessible
Useful when file has not yet been created.
-F same as --follow=name --retry
tail -F xx
tail: cannot watch 'xx': Permission denied
tail: 'xxxx' has become inaccessible: Permission denied
tail: 'xxxx' has become accessible
tail: cannot open 'xx' for reading: No such file or directory
tail: 'xx' has appeared;  following end of new file

ii

tail: xx: file truncated
1
2

1
2

tail: xx: file truncated
1
2

tail: 'xx' has become inaccessible: No such file or directory
-s S
--sleep-interval=s
with -f, sleep for s seconds (default 1) between iterations.
--max-unchanged-stats=n with --follow=name, reopen a FILE which has not changed size after n (default 5) iterations to see if it has been unlinked or renamed (incase of rotated log files).
-v
--verbose
output headers giving file names
==> heas.1.txt <==
-q
--quiet
--silent
don't output headers giving file names
--help
--version 8.26

Errors

1 file not accessable 130 tail ended while waiting for file