findstr

How to use OR operator in findstr command from a windows 7 command prompt?

不羁的心 提交于 2019-12-10 15:16:47
问题 Findstr is supposed to support regular expressions and the way I am using it I need to have an 'or' to check if a file ends in ".exe" or ".dll". However I cannot get the or operation to work. When using '|' windows thinks I am trying to pipe the previous command and 'OR' is read as literally OR 回答1: findstr.exe in Windows system32 directory supports only a very limited set of regular expression characters. Running in a command prompt window findstr /? results in getting displayed help for

piping findstr's output

心不动则不痛 提交于 2019-12-10 00:32:44
问题 Windows command line, I want to search a file for all rows starting with: # NNN "<file>.inc" where NNN is a number and <file> any string. I want to use findstr, because I cannot require that the users of the script install ack. Here is the expression I came up with: >findstr /r /c:"^# [0-9][0-9]* \"[a-zA-Z0-9_]*.inc" all_pre.txt The file to search is all_pre.txt . So far so good. Now I want to pipe that to another command, say for example more . >findstr /r /c:"^# [0-9][0-9]* \"[a-zA-Z0-9]*

在文件夹下所有文件中查找字符串(linux/windows)

人盡茶涼 提交于 2019-12-09 12:21:57
在linux下可以用 grep "String" filename.txt #字符串 文件名 grep -r "String" /home/ #递归查找目录下所有文件 来查找单个文件或者目录下所有文件是否包含某个字符串 windows下同样可以实现类似功能 findstr可以完成这个工作。 findstr /s /i "string" *.* 上面的命令表示,当前目录以及当前目录的所有子目录下的所有文件中查找"string"这个字符串。 *.*表示所有类型的文件。 /s 表示当前目录以及所有子目录 /i 表示不区分大小写 可以参考help findstr的输出解释来使用此命令。 注意: findstr.exe一般在C:\Windows\System32目录下,要从任意路径调用该命令,需要将C:\Windows\System32添加到path环境变量中,如果没加环境变量可以这样用 C:\Windows\System32\findstr.exe /s /i "string" *.* 来源: https://www.cnblogs.com/bensonyang/p/12010205.html

FINDSTR and skipping folders

本小妞迷上赌 提交于 2019-12-08 21:28:23
问题 I'm new to Windows batch programming and to Stack Overflow, so please forgive me if I ask anything that's blatantly obvious to you seasoned, talented folks. I'm using Windows batch (.bat) to find files containing a certain string using findstr . However, I'm trying to skip certain folders within a directory. setlocal EnableDelayedExpansion set basedir=C:\folder for /f %%g in ('dir /a:-h /b %basedir% ^| findstr /v "Projects" ^| findstr /v "Archive"') do ( findstr /i /m /s /c:"request" %basedir

findstr multiple search in one single output line

混江龙づ霸主 提交于 2019-12-08 10:40:39
问题 I have multiple text files that contains 3 lines of information that I want to output as one single line for each file Example File1.txt contains User: "John" Date: "13-March-2017" Time: "10.30am" Remarks: "xcvsfas" File2.txt contains User: "Mary" Date: "13-March-2017" Time: "11.30am" Remarks: "xerteyas" My expected output is as follows c:\temp\file1.txt:User: "John"; Date: "13-March-2017"; Time: "10.30am" c:\temp\file2.txt:User: "Mary"; Date: "13-March-2017"; Time: "11.30am" I tried findstr

How to redirect batch reg query output with findstr?

独自空忆成欢 提交于 2019-12-08 05:44:54
问题 This script is only a portion of about 200-300 registry statements from the original full file. It sets all registry settings as per each reg add statement.However, applying this script obviously could break something or everything. The script will be applied on a Windows 2008 R2 server. Original statement reg add "HKEY_LOCAL_MACHINE\System\CurrentControlSet\Control\Lsa" /v RestrictAnonymous /t REG_DWORD /d 1 /f What I want to accomplish before applying this script is: 1. Query each key to

Extract a line with a string with double quote by using findstr

半世苍凉 提交于 2019-12-08 05:16:09
问题 First of all thank you for this site, I'm a terrible coder and so i need your help with making a batch script, i try to extract only lines that contains Copy " in that line from a text file by using findstr which actually works without that whitespace and double quote. But it will extract the line with "Copy and Help" too which i don't need. Example: My text contains (source.txt) a asd Copy and help with these command prompt: a asd Copy "c:\.." a b c(white space) a asd Copy and help with

网络测试的window bat脚本分析

爱⌒轻易说出口 提交于 2019-12-08 04:37:48
测试脚本内容如下: @ echo off :: 设置窗口底色为绿色 color 2 F title 网络连通性检测 echo . echo . ping -n 2 223 . 5 . 5 . 5 > %temp% \ 1 . ping & ping -n 2 223 . 6 . 6 . 6 >> %temp% \ 1 . ping :: ping 阿里公共DNS findstr "TTL" %temp% \ 1 . ping > nul if %errorlevel% == 0 ( echo √ 外网正常) else ( echo × 外网不通) ::根据返回值输出 echo . ping -n 2 192 . 168 . 0 . 1 > %temp% \ 2 . ping findstr "TTL" %temp% \ 2 . ping > nul if %errorlevel% == 0 ( echo √ 网关正常) else ( echo × 网关不通) echo . ping -n 2 192 . 168 . 0 . 3 > %temp% \ 3 . ping findstr "TTL" %temp% \ 3 . ping > nul if %errorlevel% == 0 ( echo √ 内网正常) else ( echo × 内网不通) echo . ping -n

Check if user input is in txt file, with batch

家住魔仙堡 提交于 2019-12-08 02:03:29
问题 I am making a chat style system in batch for LAN networked computers. I want to check if a username is taken or not and if it is not allow it to be picked, How can I check if what the user inputs in this line (set /p name2=) I have tried this in a test file, but cant get it to work :startup set "fail=" set "name2=" set /p "name2=Enter Your Username: " cls findstr /b /e /l /c:"%name2%" <"Users.twml" >nul || set fail=1 if defined fail ( goto nope ) :yes cls echo yes, you can use that echo >>

GitLab runner on Windows and dealing with & %ERRORLEVEL%

一世执手 提交于 2019-12-08 00:29:43
问题 In my .gitlab-ci.yml, i am trying to use the findstr command. findstr /c:"%SOLUTION_DIR%" gitlab.dif > founded.ref This command set the %ERRORLEVEL% to 1 if it has no match of "%SOLUTION_DIR%" in gitlab.dif. It seems like GitLab runner is interpreting this as a job failure. ERROR: Job failed: exit status 1 Is there any workaround? EDIT : my .gitlab-ci.yml file stages: - check - build check_diff: stage: check script: - git diff --name-only origin/develop...HEAD > _gitlab_diff.txt - git diff -