Linux Log view-head command usage introduction, linux Log head command

Source: Internet
Author: User

Linux Log view-head command usage introduction, linux Log head command

The head command is used to display content starting with a file. By default, the head command displays the first 10 lines of the file.

NAME (NAME) head-output the first part of files part of SYNOPSIS (summary, outline) head [OPTION]... [FILE]... DESCRIPTION (DESCRIPTION) Print the first 10 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. print the first 10 lines of each file to the standard output. If more than one file is specified, the file name is given as the file header before each output. If no file is specified or the file is-, it is read from the standard input. Mandatory arguments to long options are required when using short options. -C, -- bytes = [-] K print the first K bytes of each file; with the leading '-', print all but the last K bytes of each file output start with K bytes; or use-c-K, from the beginning of each file to the last K bytes-n, -- lines = [-] K print the first K lines instead of the first 10; with the leading '-', print all but the last K lines of each file to output the starting K rows instead of the starting 10 rows; or use-n-K, from the beginning of each file to the last K rows-q, -- quiet, -- silent never print headers giving file names when there are multiple file parameters, do not output each file name;-v, -- verbose always print headers giving file names when there are multiple file parameters, each file name is always output; -- help display this help and exit displays this help information and exits -- version output version information and exit displays the version information and exits

1. The output starts with 100 characters

[root@peipei3514 usr]# head -c 100 test.log1 2018-03-02 12:39:06:698 YZXBB2 2018-03-03 12:40:16:700 VGLHY3 2018-03-04 12:41:17:701 XANRN4[root@peipei3514 usr]#

2. Output data from the beginning to the last 6,500th copies

[root@peipei3514 usr]# head -c -6500 test.log1 2018-03-02 12:39:06:698 YZXBB2 2018-03-03 12:40:16:700 VGLHY3 2018-03-04 12:41:17:701 XANRN4 2018-03-05 12:42:22:701 RXNYJ5 2018-03-06 12:43:14:701 BBUEM6 2018-03-07 12:44:14:701 FKYDL7 2018-03-08 12:45:08:701 KAHMA8 2018-03-09 12:46:14:702 GZZXG9 2018-03-10 12:47:16:702 OEVDO10 2018-03-11 12:48:06:702 ALXQQ11 2018-03-12 12:49:10:702 HOCSQ12 2018-03-13 12:50:10:702 [root@peipei3514 usr]#

+ Or empty, counting from scratch

-, Count from the end

3. Specify multiple files and output file names

[root@peipei3514 usr]# head -v test.log test2.log==> test.log <==1 2018-03-02 12:39:06:698 YZXBB2 2018-03-03 12:40:16:700 VGLHY3 2018-03-04 12:41:17:701 XANRN4 2018-03-05 12:42:22:701 RXNYJ5 2018-03-06 12:43:14:701 BBUEM6 2018-03-07 12:44:14:701 FKYDL7 2018-03-08 12:45:08:701 KAHMA8 2018-03-09 12:46:14:702 GZZXG9 2018-03-10 12:47:16:702 OEVDO10 2018-03-11 12:48:06:702 ALXQQ==> test2.log <==201 2018-09-18 18:50:25:778 ZHWKD202 2018-09-19 18:51:26:778 VQGRP203 2018-09-20 18:52:37:779 UZDCE204 2018-09-21 18:53:40:779 NCISH205 2018-09-22 18:54:34:779 ZCJUY206 2018-09-23 18:55:38:779 SEJKZ207 2018-09-24 18:56:27:779 CNGMW208 2018-09-25 18:57:31:779 GLILU209 2018-09-26 18:58:24:779 VWUSO210 2018-09-27 18:59:39:779 HDRAT

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.