Linux Centos 文件查看 如何显示最后几行 ,某几行

  1.显示最后20行

      tail -n 20 文件名

    

      如tail -n 20  log.txt

 

  2.显示中间20,从1000开始

     cat  log.txt|tail -n +1000|head -n 20               

 

    注:tail -n +行号   意思为 从第多少行开始  ,如果是 tail -n -行  == tail -n 行 意思为文件末尾多少行的数据  

           head -n 20  前20行的数据

 

 3.也可以用sed命令

 

  如 sed -n '100,120p' log.txt   100 到120行的数据。

===================== This is my sign! ======================================================= The moment you want to give up, thing about why did insist to come here !
原文地址:https://www.cnblogs.com/tuozi001/p/2855617.html