我正在使用批处理脚本从位置(特定于用户)
读取日志文件输入搜索字符串由用户输入;
如果找到字符串,请将整行复制到另一个文本文件中。
预期:
输入搜索字符串:ERROR或错误(/ i表示不敏感)
将包含ERROR或错误的行复制到新文本文件中。
我有这个代码:
@echo off
set /p Input=Enter some text:
echo %Input% findstr "%Input%" < C:/logfile.txt
if %errorlevel%==0 ( echo Found! logged files into newlog.txt
) else (
echo No matches found )
答案 0 :(得分:0)
这是您可以在Unix系统上执行的操作:
findstr /i "ERROR" logfile.txt > output.txt
在Windows的批处理文件中,您可以执行以下操作:
def get_best_fit(big_array, small_array):
# we assume the small array is square
patch_size = small_array.shape[0]
min_value = np.inf
for x in range(patch_size, big_array.shape[0] - patch_size):
for y in range(patch_size, big_array.shape[1] - patch_size):
p = get_patch_term(x, y, patch_size, big_array)
tmp = some_metric(p, small_array)
if min_value > tmp:
min_value = tmp
min_patch = p
return min_patch, min_value
答案 1 :(得分:0)
尝试这样的事情:
@echo off
cls & color 0B
echo(
Set /p "Location=Enter the file location to perform search> "
cls & echo(
echo You chose this location "%Location%"
echo(
set /p "Input=Enter text to search: "
set ResultFile=ResultFile.txt
findstr /r /i "%Input%" "%Location%" > %ResultFile%
if %errorlevel%==0 (cls & Color 0A & echo Found the string "%Input%" into "%Location%" !
) else (cls & Color 0C & echo No matches found "%Input%" into "%Location%" !)
Echo Hit any key to open the file "%ResultFile%" !
pause>nul
start %ResultFile%