linux - Keep top 5 lines from a file -


What do I want to do here ...

I have a bunch of text files I need to go through and keep the top 5 lines only if I do head , then output in the file that is part of that file requires the file name as it was before.

Ex.: file.name - top 5 lines (delete everything below row 5), then save the file as file.name . There are many files that will need to be done in the form of batch.

You can use head to do this

  head -n5 file.name & gt; File.name.tmp & amp; Amp; Mv file.name.tmp file.name  

You can do it for all the files as a script, in each code as a code, file.name < / Code>. Run later.


Comments