我有这个.txt
文件
ROTHSCHILD = 81; // Fondation Adolphe de Rothschild , 2019
ONCOPOLE = 82; // Oncopole - Toulouse , 2019
GHRMSA = 83; // GHR Mulhouse Sud-Alsace , 2019
CHDN = 84; // CH du Nord - Luxembourg , 2019
CAEN = 85; // CHU de Caen , 2019
MONTELIMAR = 86; // , 2019
PUYENVELAY = 87; // , 2019
我要删除所有行
CHDN = 84; // CH du Nord - Luxembourg , 2019
我怎样才能做到这一点 ?
我尝试了这个:
get-content txt.txt | % {$_ ; if($_ -eq "CHDN = 84; // CH du Nord - Luxembourg , 2019") {break }}
但是中断程序,该怎么办?
最佳答案
您可能需要做一些每次测试的事情。我会这样使用Do..Until
循环:
$txtData = get-content txt.txt
$stophere = 'CHDN = 84; // CH du Nord - Luxembourg , 2019'
$ctr = 0
Do
{
$txtData[$ctr++] #Prints data line and increments counter
} Until ($txtData[$ctr] -eq $stophere)
关于powershell - 在PowerShell中删除特定行之后的所有行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60288428/