I have a CSV file like this:
text,0
more text,2
some more text,100
I need to delete any line containing only 0
in the second column, e.g., the output of the above would be:
more text,2
some more text,100
How can I delete all lines from a CSV with an exact match?
If that's your last field, grep will do the trick:
grep -v ',0$'
If not, and your fields don't contain ,
, use awk:
awk -F , '{if ($2!='0') print}'
If it's even more complex use python or ruby with a CSV parser.
A simple sed solution...
sed /,0$/d
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With