
批量提取N個文本的指定內容行數并加入序列這是之前ivor大佬幫助別人解決 “批量提取N個文本的指定內容行數”的代碼------------------------------------------------------變量參考例子:num=1..3提取2(正數)至4(正數)行內容num=3提取第4(正數)行內容num=-3提取-3(倒數)行內容num=-1..-3提取-1(倒數)至-3(倒數)行內容num=-1..3提取-1(倒數)和 1 至 4(正數)行內容 慎用:不建議num=1,5,9提取2,6,10(正數)行內容num=-1,-5,-9提取-1,-5,-9(倒數)行內容代碼內容
----------------------------------------------------------我有一個額外的需求輸出結果的時候能否加一個序列比如我提取的是文檔的前兩行,目前代碼輸出的結果如下:- name: Fastuuid: 57e0cb4d-eae5-48ec-8071-149dc2b3ea4q- name: Fastuuid: 96e0cb4d-eare-4802-8091-149dc2b309e0想讓輸出帶序列的結果,例如:- name: Fast01uuid: 57e0cb4d-eae5-48ec-8071-149dc2b3ea4q- name: Fast02uuid: 96e0cb4d-eare-4802-8091-149dc2b309e0請問大佬如果修改一下實現(xiàn)這樣的效果呢,求指點,不勝感激nclick="copycode($('code0'));">復制代碼
- <# :
- @echo off
- rem 增強代碼兼容性,代碼保存為 .bat、.cmd、.ps1均可執(zhí)行
- powershell Set-ExecutionPolicy -ExecutionPolicy RemoteSigned
- more +8 %~f0 >%~dpn0.ps1
- powershell -File %~dpn0.ps1
- del %~dpn0.ps1 & pause & exit /b
- #>
- del 輸出結果.txt -ErrorAction SilentlyContinue
- $num = 1..3
- dir *.txt | foreach {
- $line = get-content $_
- foreach ($l in $line[$num])
- {
- -Join($_.Name, , $l) | out-file -Append 輸出結果.txt
- }
- }

