Linux Commands for Beginners--Head and Tail Command

来源:互联网 发布:无法获取摄像头数据 编辑:程序博客网 时间:2024/05/17 22:27
In this part, I go over both the head and tail commands.

1.COMMAND:
     head
DESCRIPTION:
     Print  the  first  10 lines of  FILE to standard output.
SYNOPSIS:
       head [OPTION]... [FILE]...
OPTION:
     -n, --lines
              print  the first n lines instead of the first 10;


2.COMMAND:
    tail
DESCRIPTION:
    Print the last 10 lines of FILE to standard output.
SYNOPSIS:
    tail [OPTION]... [FILE]...
OPTION:
     -n, --lines      output the last K lines, instead of the last 10;


Examples:
root@piniheaven:~/tutorial# ls
poem.txt
root@piniheaven:~/tutorial# head poem.txt   # Print  the  first  10 lines of  poem.txt to standard output.
nt you to know
one thing.

You know how this is:
if I look
at the crystal moon, at the red branch
of the slow autumn at my window,
if I touch
near the fire
the impalpable ash
root@piniheaven:~/tutorial# head -4 poem.txt   # Print  the  first 4 lines of poem.txt to standard output.
nt you to know
one thing.

You know how this is:
root@piniheaven:~/tutorial# tail poem.txt    # Print  the last  10 lines of poem.txt to standard output.
you feel that you are destined for me
with implacable sweetness,
if each day a flower
climbs up to your lips to seek me,
ah my love, ah my own,
in me all that fire is repeated,
in me nothing is extinguished or forgotten,
my love feeds on your love, beloved,
and as long as you live it will be in your arms
without leaving mine
root@piniheaven:~/tutorial# tail -3 poem.txt    # Print  the last 3 lines of poem.txt to standard output.
my love feeds on your love, beloved,
and as long as you live it will be in your arms
without leaving mine

原创粉丝点击