+3 votes
in Operating Systems by (74.4k points)
I have a very big file and want to copy first 1000 lines from that big file to a new file so that I can test my code changes quickly. How can I copy using Linux command?

1 Answer

+1 vote
by (352k points)
selected by
 
Best answer

You can use sed command to copy first 1000 lines from one file to another. You can use one of the following approaches:

$ sed -e "5000q" bpdata1.csv > bpdata2.csv
$ wc -l bpdata2.csv
5000 bpdata2.csv

$ sed -n "1,1000p" bpdata1.csv > file2.csv
$ wc -l file2.csv
1000 file2.csv


...