linux 使用笔记6

来源:互联网 发布:卡巴斯基安全软件 编辑:程序博客网 时间:2024/06/15 23:20
---恢复内容开始---

1、内容追加

     把一个文件的内容追加到另一个文件中:

          cat first.txt >> second.txt//追加到second.txt文件的末端

      cat first.txt > second.txt//覆盖second.txt文件中的内容

2、查看头,尾等

    查看头:

         head -n my.txt//-n后加所要显示的行数

    查看尾:

         tail -n my.txt//-n后加所要显示的行数

    查看特定的几行:

   从第3000行开始,显示1000行。即显示3000~3999行

      cat filename | tail -n +3000 | head -n 1000

  显示1000行到3000行

      cat filename| head -n 3000 | tail -n +1000

  用sed命令

      sed -n '5,10p' filename 这样你就可以只查看文件的第5行到第10行。

       

---恢复内容结束---