How do I limit (or truncate) text file by number of lines?
In-place truncation To truncate the file in-place with sed, you can do the following: sed -i ‘50001,$ d’ filename -i means in place. d means delete. 50001,$ means the lines from 50001 to the end. You can make a backup of the file by adding an extension argument to -i, for example, .backup or .bak: … Read more