删除不包含某些单词/短语的行

时间:2022-12-17 20:10:09

I need to remove some rows from a list.

我需要从列表中删除一些行。

I need to remove all of the rows that do not contain certain words or phrases.

我需要删除所有不包含某些单词或短语的行。

I am using code that removes certain rows. I need to change this code to save only the rows that contain certain words

我正在使用删除某些行的代码。我需要更改此代码以仅保存包含特定单词的行

I am using this code

我正在使用此代码

:: 'Remove Lines With Specific Words From Proxy List Csv'
@echo off & setlocal EnableDelayedExpansion

findstr /v "GOOD WORKING" "C:\my_list.csv" > "C:\my_list.new"
del "C:\my_list.csv"
ren "C:\my_list.new"  *.csv

I need to adapt the code to delete all rows except the rows that contain "GOOD WORKING" can you help me please ?

我需要调整代码来删除所有行,除了包含“GOOD WORKING”的行你能帮我吗?

1 个解决方案

#1


Ehm - I object!

嗯 - 我反对!

findstr /v "GOOD WORKING" "C:\my_list.csv" > "C:\my_list.new"

shows all lines that do not contain either GOOD or WORKING.

显示所有不包含GOOD或WORKING的行。

findstr "GOOD WORKING" "C:\my_list.csv" > "C:\my_list.new"

shows all lines that contain either GOOD or WORKING.

显示包含GOOD或WORKING的所有行。

findstr /v /C:"GOOD WORKING" "C:\my_list.csv" > "C:\my_list.new"

shows all lines that do not contain GOOD WORKING.

显示所有不包含GOOD WORKING的行。

findstr /C:"GOOD WORKING" "C:\my_list.csv" > "C:\my_list.new"

shows all lines that contain GOOD WORKING.

显示包含GOOD WORKING的所有行。

Unless preceded by the /c: switch, the target string is a space-separated list of words.

除非前面是/ c:开关,否则目标字符串是以空格分隔的单词列表。

#1


Ehm - I object!

嗯 - 我反对!

findstr /v "GOOD WORKING" "C:\my_list.csv" > "C:\my_list.new"

shows all lines that do not contain either GOOD or WORKING.

显示所有不包含GOOD或WORKING的行。

findstr "GOOD WORKING" "C:\my_list.csv" > "C:\my_list.new"

shows all lines that contain either GOOD or WORKING.

显示包含GOOD或WORKING的所有行。

findstr /v /C:"GOOD WORKING" "C:\my_list.csv" > "C:\my_list.new"

shows all lines that do not contain GOOD WORKING.

显示所有不包含GOOD WORKING的行。

findstr /C:"GOOD WORKING" "C:\my_list.csv" > "C:\my_list.new"

shows all lines that contain GOOD WORKING.

显示包含GOOD WORKING的所有行。

Unless preceded by the /c: switch, the target string is a space-separated list of words.

除非前面是/ c:开关,否则目标字符串是以空格分隔的单词列表。