+2 votes
in Operating Systems by (15.7k 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

0 votes
by (27.1k points)

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