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:
- first find number of rows in the file by opening the file (it was way less then 100)
- 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’.