2

I have a list of roughly 100 entries to be deleted from a csv-delimited file. They are already in another text file called 'tbd.txt;

My first thought is to write a bash for loop around 'sed -i' but that seems horribly wasteful of disk i/o.

Is there a better way to have sed parse the file of deletions internally? There is a similar problem here but the solution doesn't seem scalable.

1
  • Please edit your question and provide us with i) an example of your input data (both files) and desired output ii) an explanation of your data. Can you have things like field1, "field2A,field2B"? can your fields contain newlines? How about wildcards? iii) do you want to remove the entire line for each match or only a specific field?
    – terdon
    Commented Mar 9, 2015 at 17:31

1 Answer 1

2

You can use sed to process tbd.txt and create a sed script from it which would delete the lines. Something like

sed 's=^=/=;s=$=/d=' tbd.txt | sed - file.csv

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .