zoukankan      html  css  js  c++  java
  • 每天一个linux命令:head(15)

    head

    head命令用于显示文件的开头的内容。在默认情况下,head命令显示文件的头10行内容。

    格式

    head [参数] [文件]

    参数选项

    参数 备注
    -q 不显示文件名的头信息
    -v 总是显示文件名的头信息
    -c <字节> 显示字节数
    -n <行数> 显示的行数

    实例

    • 显示文件的前n行

      命令: **head -n 5 myFile **

    [root@VM_0_9_centos ~]# cat myFile
    this is line 1;
    this is line 2;
    this is line 3;
    tihs is line 4;
    this is line 5;
    this is line 6;
    this is line 7;
    this is line 8;
    this is line 9;
    this is line 10;
    this is line 11;
    this is line 12;
    this is line 13;
    this is line 14;
    [root@VM_0_9_centos ~]# head -n 5 myFile
    this is line 1;
    this is line 2;
    this is line 3;
    tihs is line 4;
    this is line 5;
    
    • 显示文件前n个字节

      命令: **head -c 10 myFile **

    [root@VM_0_9_centos ~]# head -c 10 myFile
    this is li
    [root@VM_0_9_centos ~]# 
    
    • 文件的除了最后n个字节以外的内容

    命令: **head -c -10 myFile **

    root@VM_0_9_centos ~]# head -c 10 myFile
    this is li[root@VM_0_9_centos ~]# head -c -10 myFile
    this is line 1;
    this is line 2;
    this is line 3;
    tihs is line 4;
    this is line 5;
    this is line 6;
    this is line 7;
    this is line 8;
    this is line 9;
    this is line 10;
    this is line 11;
    this is line 12;
    this is line 13;
    this is
    [root@VM_0_9_centos ~]# 
    
    • 输出文件除了最后n行的全部内容

      命令: **head -n -6 myFile **

    [root@VM_0_9_centos ~]# head -n -10 myFile
    this is line 1;
    this is line 2;
    this is line 3;
    tihs is line 4;
    [root@VM_0_9_centos ~]# 
    

    参考

  • 相关阅读:
    git命令
    Java开发中的23种设计模式详解
    Linux下简单基本操作【备查】
    微信|公众平台开发者平台
    MyEclipse老是弹出problem occurred窗口
    spring 工具包怎么下载
    MyEclipse8.6启动后提示内存不足的解决方案(亲测,完美解决)
    bzoj2440,luoguP4318 完全平方数
    hdu5528
    CF1076E Vasya and a Tree
  • 原文地址:https://www.cnblogs.com/DiDi516/p/11789132.html
Copyright © 2011-2022 走看看