Skip to content
Advertisement

How do I copy first 3 lines and last 2 lines of a file, and create new file [closed]

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

Advertisement

Answer

head -n 3 moja.txt > kombinacija.txt &&
  tail -n -2 moja.txt >> kombinacija.txt
User contributions licensed under: CC BY-SA
4 People found this is helpful
Advertisement