What is the equivalent of this statement in batch?
批量处理这个陈述的等价物是什么?
awk '/-imsi/ {print $NF "\r"}' "IMSI$r.txt" | tee -a out > "N$r"
This statement is in a loop were the variable r is incremented. It will search in the text file for -imsi and take the last recordfield after it, then save the output in 2 files, out and Nr.txt
如果变量r递增,则该语句处于循环中。它将在文本文件中搜索-imsi并获取其后的最后一个记录字段,然后将输出保存为2个文件,out和Nr.txt
I couldn't find any batch command that replaces the awk command.
我找不到任何替换awk命令的批处理命令。
1 个解决方案
#1
2
Excuse me, I don't know UNIX awk feature. However, the Batch commands below search in the IMSIr.txt file for "-imsi" string and take the string immediately after it; then save the output in 2 files, out (with all output lines) and Nr.txt:
对不起,我不懂UNIX awk功能。但是,下面的Batch命令在IMSIr.txt文件中搜索“-imsi”字符串并在其后立即获取字符串;然后将输出保存在2个文件中,输出(包括所有输出行)和Nr.txt:
for /F "delims=" %%a in ('findstr /C:"-imsi" IMSIr.txt') do set line=%%a
for /F %%a in ("%line:*-imsi=%") do echo %%a>> out & echo %%a> Nr.txt
For example, with this input file:
例如,使用此输入文件:
Previous line
Target line: -imsi 376 another values
Posterior line
The output is "376".
输出为“376”。
The modification below include a loop where the variable %%r is incremented thru a certain range:
下面的修改包括一个循环,其中变量%% r递增到一定范围:
@echo off
setlocal EnableDelayedExpansion
set N=3
for /L %%r in (1,1,%N%) do (
for /F "delims=" %%a in ('findstr /C:"-imsi" IMSI%%r.txt') do set line=%%a
for /F %%a in ("!line:*-imsi=!") do echo %%a>> out & echo %%a> N%%r.txt
)
If this is not what you want, please describe the desired changes.
如果这不是您想要的,请描述所需的更改。
#1
2
Excuse me, I don't know UNIX awk feature. However, the Batch commands below search in the IMSIr.txt file for "-imsi" string and take the string immediately after it; then save the output in 2 files, out (with all output lines) and Nr.txt:
对不起,我不懂UNIX awk功能。但是,下面的Batch命令在IMSIr.txt文件中搜索“-imsi”字符串并在其后立即获取字符串;然后将输出保存在2个文件中,输出(包括所有输出行)和Nr.txt:
for /F "delims=" %%a in ('findstr /C:"-imsi" IMSIr.txt') do set line=%%a
for /F %%a in ("%line:*-imsi=%") do echo %%a>> out & echo %%a> Nr.txt
For example, with this input file:
例如,使用此输入文件:
Previous line
Target line: -imsi 376 another values
Posterior line
The output is "376".
输出为“376”。
The modification below include a loop where the variable %%r is incremented thru a certain range:
下面的修改包括一个循环,其中变量%% r递增到一定范围:
@echo off
setlocal EnableDelayedExpansion
set N=3
for /L %%r in (1,1,%N%) do (
for /F "delims=" %%a in ('findstr /C:"-imsi" IMSI%%r.txt') do set line=%%a
for /F %%a in ("!line:*-imsi=!") do echo %%a>> out & echo %%a> N%%r.txt
)
If this is not what you want, please describe the desired changes.
如果这不是您想要的,请描述所需的更改。