Reputation: 657
I am just learning to work with csv files from the command line. I want to delete several lines from a file using sed
. I've removed the header of a file with this cat file.csv | sed 1,2d > file.csv
.
Now I want to delete several more lines from the file (lines 3, 10, 12, and 28-35) and I am not sure how to pull it off. I'd be grateful for any help.
Upvotes: 3
Views: 3968
Reputation: 41232
Depending on the sed implementation, you could separate them as follows:
cat file.csv | sed "1,2d;10d;12d;28,35d" > file2.csv
Upvotes: 4
Reputation: 385500
Use the -e
flag to pass several commands to one sed
invocation, like this:
seq 1 40 | sed -e 1,2d -e 3d -e 10d -e 12d -e 28,35d
Upvotes: 2