How to Remove the First Row of a File

Question - I have a file and I want to remove the first row of the file

Answer - There are several ways to remove the first row of a file:

  • sed "1 d" <file_name> > <new_file_name>

       Example sed "1 d" test_file > test_file_new

       In-case that you want to remove more than one row use the following                    command: sed "1,2 d" <file_name> > <new_file_name>

  • tail -n +2 <file_name> > <new_file_name>

      The -n +2 means “start passing through on the second line of output”

  • 31
  • 13-Jul-2015