下面的代码, 排除空行没问题, 但是排除带-和:的行不生效- (gc "C:\Users\Administrator\Desktop\a.txt") |
- ? { $_.trim() -ne "" } |
- ? { $_.trim() -notcontains ":" } |
- ? { $_.trim() -notcontains "-" } |
- sc "C:\Users\Administrator\Desktop\aa.txt" -Encoding UTF8
复制代码 a.txt内容:
目标是删除下面四行:
[00:00.10]胡歌 - 逍遥叹
[00:00.70]作词:陈宇任
[00:00.89]作曲:陈宇任
[00:01.00]编曲:屠颖
-----------------------------------------
[ar:胡歌]
[ti:逍遥叹]
[00:00.10]胡歌 - 逍遥叹
[00:00.70]作词:陈宇任
[00:00.89]作曲:陈宇任
[00:01.00]编曲:屠颖
[00:26.68]岁月难得沉默
[00:29.92]秋风厌倦漂泊
[00:33.24]夕阳赖着不走
[00:35.64]挂在墙头舍不得我
[00:39.91]昔日伊人耳边话 |