Home > Net >  How do I copy first 3 lines and last 2 lines of a file, and create new file
How do I copy first 3 lines and last 2 lines of a file, and create new file

Time:03-24

So I've a question how do I copy first 3 lines and last 2 files in linux and put them into new file

So I have file: moja.txt and content in this file is

(Name)
1
2
3
4
5
6
7
8
9
10

and I'd like to make new file kombinacija.txt and content in this file would be:

(Name)
1
2
9
10

CodePudding user response:

head -n 3 moja.txt > kombinacija.txt &&
  tail -n -2 moja.txt >> kombinacija.txt
  • Related