Wednesday, January 13, 2016

[Terminal] - How to get last n lines from file


I want create a file with last 10 lines from big-data-file.txt

big-data-file.txt (contains 100 lines)
1
2
3
4
5
...
96
97
98
99
100

to do that, open command line and execute:

tail -n 10 big-data-file.txt > small-file.txt

Where 10 is the number of lines you want

the results is:

small-file.txt (contains 10 lines)
91
92
93
94
95
96
97
98
99
100


No comments :

Post a Comment