Chopping a file - get the first rows from a CSV (or other) file

Question - I have a file and I want to extract the first few lines from it

Answer - On Linux, you can use the head -n command 

Syntax

head -n <numbers_of_rows> <old_file_name> > <new_file_name>

Example

Top 100 rows from a CSV file:

$ head -n 100 file.csv > chopped.csv

  • 32
  • 19-Jul-2015
  • 612 Views