findstr

Get specific string from a text file using batch command [closed]

佐手、 提交于 2020-01-17 15:16:40
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I am looking for a Windows batch script command that can extract specific data string from an automatically generated text file. Note that the first line in the test.txt file is always empty. I need to extract only " 2017/01/01-01 " (from the 2nd line) to a different file. Findstr

Get specific string from a text file using batch command [closed]

对着背影说爱祢 提交于 2020-01-17 15:16:07
问题 Closed . This question needs to be more focused. It is not currently accepting answers. Want to improve this question? Update the question so it focuses on one problem only by editing this post. Closed 2 years ago . I am looking for a Windows batch script command that can extract specific data string from an automatically generated text file. Note that the first line in the test.txt file is always empty. I need to extract only " 2017/01/01-01 " (from the 2nd line) to a different file. Findstr

Python查看已安装库的版本

北战南征 提交于 2020-01-17 13:33:11
Python查看已安装库的版本 以查看numpy的版本为例。 目录 一、Linux系统 1、Python2 2、Python3 二、Windows系统 1、Python2 2、Python3 一、Linux系统 1、Python2 pip2 list | grep numpy 运行上面的命令输出: numpy (1.15.4) 1.15.4就是库的版本号。pip list会列出所有安装的库;|是重定向输出符号,把pip list的输出重定为grep命令的输入;grep命令是从输入中找到包含numpy那一行并打印出来,如果没有找到,则没有输出。 2、Python3 pip3 list | grep numpy 二、Windows系统 1、Python2 pip2 list | findstr numpy 运行上面的命令输出: numpy 1.16.2 1.16.2就是版本号。findstr类似于linux系统的grep命令,如果没有找到,则没有输出。 2、Python3 pip3 list | findstr numpy 原文信息: 声明:本文为CSDN博主「原我归来是少年」的原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接及本声明。 原文链接:https://blog.csdn.net/DumpDoctorWang/article/details

BATCH/CMD: Print each line of a .txt into a variable

China☆狼群 提交于 2020-01-16 12:46:12
问题 Goal: Have every dll file in a computer passed into regsvr32.exe Accomplished: cd\ ::REM Exports every file and directory (/s) into a file in root of c: called dir.txt with only file names (/b) dir /s /b>>dir.txt ::REM Now, this will contain every extension type. We only want dll's, so we findstr it into dll.txt: findstr ".dll$" dir.txt>>dll.txt The Kink: Now, if I want to regsvr32.exe "file" every file that is now in dll.txt, I somehow need to get out every individual filename that is

BATCH/CMD: Print each line of a .txt into a variable

▼魔方 西西 提交于 2020-01-16 12:43:52
问题 Goal: Have every dll file in a computer passed into regsvr32.exe Accomplished: cd\ ::REM Exports every file and directory (/s) into a file in root of c: called dir.txt with only file names (/b) dir /s /b>>dir.txt ::REM Now, this will contain every extension type. We only want dll's, so we findstr it into dll.txt: findstr ".dll$" dir.txt>>dll.txt The Kink: Now, if I want to regsvr32.exe "file" every file that is now in dll.txt, I somehow need to get out every individual filename that is

BATCH/CMD: Print each line of a .txt into a variable

↘锁芯ラ 提交于 2020-01-16 12:43:30
问题 Goal: Have every dll file in a computer passed into regsvr32.exe Accomplished: cd\ ::REM Exports every file and directory (/s) into a file in root of c: called dir.txt with only file names (/b) dir /s /b>>dir.txt ::REM Now, this will contain every extension type. We only want dll's, so we findstr it into dll.txt: findstr ".dll$" dir.txt>>dll.txt The Kink: Now, if I want to regsvr32.exe "file" every file that is now in dll.txt, I somehow need to get out every individual filename that is

How to use findstr to search for multiple strings in one line

本秂侑毒 提交于 2020-01-14 03:35:09
问题 So I want to be able to search for the string "[ FAILED ]" and the string "." that are both on the same line inside of a text file. How would I do this? I tried this: FINDSTR /C:"[ FAILED ]" /C:"." output_.txt but it produces lines that contain either of the strings. If possible I also want to be able to exclude any lines that contain numbers from my finds. 回答1: I have answered my own question using piping and coming up with the following command: FINDSTR /C:"[ FAILED ]" output_.txt | FINDSTR

Batch Script to delete files based on findstr regex

久未见 提交于 2020-01-13 18:08:47
问题 I'm trying to delete some files with a batch script, based on a regular expression. What I have is: FOR /f "tokens=*" %%a in ('dir /b | findstr MY_REGEX_HERE') DO ECHO %%a I know my inner command works on its own, giving me the list of directories, but when I embed it in the for loop like this I get an error | was unexpected at this time. Is piping not allowed within FOR loop commands? Or do I need to escape it or something? Any help on how I can do this would be great. 回答1: FOR /f "tokens=*"

findstr的命令行分析机制

末鹿安然 提交于 2020-01-12 20:12:15
来源:http://www.cn-dos.net/forum/viewthread.php?tid=21167&fpage=1&highlight=findstr willsort 版主 To All: 问题缘起于bsijl一篇关于findstr错误过滤的主题[1],当时因为无法找到原因,所以只能推测 /g 开关存在某些问题。 近日,因为编写一个debuger代码,再次使用了 findstr/g ,结果遇到了同样的问题[2]。经过仔细的测试[3]后,发现是 findstr 特殊的命令行分析机制所引起的问题。略述如下: 1、findstr不同于早期的find,它对参数的排列有一定的要求,即遵循开关(可省略)、字符串(使用/c开关时省略)、文件名(可通配、可多个、有输入流时需省略)的顺序。 2、开关可以使用引号,所以不能直接以与开关相同的关键字进行搜索;文件名含空格时必须用引号。 3、搜索关键字的情况和表现就比较复杂,分述如下: 3-1、无论是否使用开关/l或/r以及是否使用引号,关键字中的\都会成为转义字符,所以\\将成为\,\"将使引号失去字符串界定作用; 3-2、搜索关键字可加或不加引号,当加引号时其中的\可能会再次转义。使用开关/l和/r时的转义结果可能会不同:当使用/r时,所以"\\\\"将成为单个\,"\\"将使关键字为空;当使用/l或均不使用时,"\\\\"和"\\

Findstr - Return only a regex match

二次信任 提交于 2020-01-10 05:02:06
问题 I have this string in a text file ( test.txt ): BLA BLA BLA BLA BLA Found 11 errors and 7 warnings I perform this command: findstr /r "[0-9]+ errors" test.txt In order to get just 11 errors string. Instead, the output is: Found 11 errors and 7 warnings Can someone assist? 回答1: The findstr tool cannot be used to extract matches only. It is much easier to use Powershell for this. Here is an example: $input_path = 'c:\ps\in.txt' $output_file = 'c:\ps\out.txt' $regex = '[0-9]+ errors' select