Using SED to Get the Last n Lines of a Huge Text File

后端 未结 3 981
执念已碎
执念已碎 2021-01-04 18:38

How can I use \"sed\" command to get the last n lines of a huge text file (e.g. A.txt) and copy them into a new text file(e.g. B.txt)? I do not want to remove that lines fro

3条回答
  •  不知归路
    2021-01-04 18:54

    Here's how to use sed to print the last 10 lines of a file:

    sed -e :a -e '$q;N;11,$D;ba' 
    

    You should probably only use this if you're planning on executing more sed commands on these lines. Otherwise the tail command is designed for this job.

提交回复
热议问题