Alternative way to delete rows from csv in bash terminal

In the Relational Database Course ‘Building a Student Database Part 1’, there are few tasks to delete rows from a csv from bash terminal.

No code solution is given, so I presume was to be done manually.

How can this be done via code? I did it using this process:

  1. first find number of rows in the file by opening the file (it was way less then 100)
  2. Run in the terminal: sed 6,100d input.csv > output.csv
    The above deletes rows beyond 5th, till 100th row.

Are there any better ways?
Example, where step 1 need not be checked once and its possible to enter something like ‘>=6d’ instead of ‘6,100d’.

First, define “better”?

added one way. Thanks

All commands can be automated in code. For eg using a bash script. Is this what you wanted to know?

Looking to better the line ‘sed 6,100d input.csv > output.csv’, as this depends on previous step of checking to if ‘100d’ is enough or not.

Another way to use sed is like this

sed '6,$d' input.csv 

This should delete everything to the end