findstr

findstr or grep that autodetects chararacter encoding (UTF-16)

不想你离开。 提交于 2019-11-30 01:41:03
问题 I want to do this: findstr /s /c:some-symbol * or the grep equivalent grep -R some-symbol * but I need the utility to autodetect files encoded in UTF-16 (and friends) and search them appropriately. My files even have the byte-ordering mark FFEE in them so I'm not even looking for heroic autodetection. Any suggestions? I'm referring to Windows Vista and XP. 回答1: Thanks for the suggestions. I was referring to Windows Vista and XP. I also discovered this workaround, using free Sysinternals

Why does `findstr` with variable expansion in its search string return unexpected results when involved in a pipe?

☆樱花仙子☆ 提交于 2019-11-29 21:20:10
问题 While trying to provide a comprehensive answer to the question Why is FindStr returning not-found, I encountered strange behaviour of code that involves a pipe. This is some code based on the original question (to be executed in a batch-file): rem // Set variable `vData` to literally contain `...;%main%\Programs\Go\Bin`: set "vData=...;%%main%%\Programs\Go\Bin" set "main=C:\Main" echo/%vData%| findstr /I /C:"%%main%%\\Programs\\Go\\Bin" This does not return a match, hence nothing is echoed

Help with SubString in SSIS

*爱你&永不变心* 提交于 2019-11-29 18:44:38
Hallo All, I have a little Problem with the SubString-Function in SSIS (Derived Column). So on.. That are the possible Input Strings: Toys|Category|Cars|Lego Toys|Hot&New|Girls&Lifestyle|Doll Toys|New Barbies|Category|Mobile I need to filter the word after the Second " | ". In first case: "Cars" In the second case: "Girls&Lifestyle" In the third case: "" In the fourth case: "Mobile" My try was: SUBSTRING(Category,FINDSTRING(Category,"|",2)+1,FINDSTRING(Category,"|",3)) It doesn't work because the FINDSTRING(Category,"|",3) gives the index but I need the lenght of the Word!! How can i count the

How can I use findstr with newline regular expression

Deadly 提交于 2019-11-29 15:47:52
I'm on windows dos prompt. I have log file which contains log like: Timestamp: Order received for Item No. 26551 Timestamp: Exception: OutOfRangeException Timestamp: Message: Inventory Item is not stock. Item No. 23423 Timestamp: Order received for Item No. 23341 I want to extract all the item number who has give some sort of exception. I'm using findstr command for this. how can I use newline in my regular expression? I want to all lines which have Exception word and from next line the item no. any help? I've discovered an undocumented feature - FINDSTR CAN match new line characters <CR> and

Findstr - Return only a regex match

自作多情 提交于 2019-11-29 14:13:02
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? 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-string -Path $input_path -Pattern $regex -AllMatches | % { $_.Matches } | % { $_.Value } > $output_file See the

Windows查看端口使用状况(转)

本小妞迷上赌 提交于 2019-11-29 07:07:06
转: https://www.cnblogs.com/lixuwu/p/5898354.html 阅读目录 1 查看windows所有端口进程 2 查询指定端口 使用端口是我们在进行远程或者打印机等都会遇到的,但是有很多用户会遇到端口被占用的情况,遇到这样的问题首先就要找出电脑中的所以端口然后进行查看,还是有很多人不知道该如何查看电脑端口。 回到顶部 1 查看windows所有端口进程 首先点击开始菜单选择运行,接着在运行对话框中输入“cmd”,回车打开命令提示符窗口,然后在窗口中输入 netstat -ano ,按下回车,之后就会显示所有的端口占用情况。 回到顶部 2 查询指定端口 如果你要查询指定的端口占用的话,可以在窗口中继续输入 netstat -aon|findstr "指定的端口" ,这里的提示的端口假设为80,那么就输入命令为【netstat -aon|findstr "80"】,回车之后就可以看见列表中的PID,然后根据PID在电脑的任务管理器中查看对应的占用程序,然后将其关闭即可。 然后根据查询的PID找到对应的进程,我么可以看到占有80这个程序的进程ID:2432,继续输入命令 tasklist|findstr "2432" ,2432就是进程ID,现在知道是哪个进程占用的我们就可以采取相应措施进行解决了。 转: https://www.cnblogs.com

Help with SubString in SSIS

不打扰是莪最后的温柔 提交于 2019-11-28 13:19:32
问题 Hallo All, I have a little Problem with the SubString-Function in SSIS (Derived Column). So on.. That are the possible Input Strings: Toys|Category|Cars|Lego Toys|Hot&New|Girls&Lifestyle|Doll Toys|New Barbies|Category|Mobile I need to filter the word after the Second " | ". In first case: "Cars" In the second case: "Girls&Lifestyle" In the third case: "" In the fourth case: "Mobile" My try was: SUBSTRING(Category,FINDSTRING(Category,"|",2)+1,FINDSTRING(Category,"|",3)) It doesn't work because

批处理

∥☆過路亽.° 提交于 2019-11-28 07:16:29
批处理 echo 输出文字 例子 结果 @echo off 关闭回显 echo. 回车 echo Y|rd /s c:\abc 用rd 命令删除时,自动输入Y确认 echo 123>myfile.txt 新建文件,将123输入进去,如果有文件,覆盖 rem :: 注释 rem 在某些场合下将比 :: 更为适用 cd 目录切换 例子 结果 cd… 返回到上一层目录 cd\ 返回根目录 cd. 当前目录 cd /d d:\123\abc 切换到D:\123\abc echo 当前路径是 %cd% 显示当前的完整路径,一般用通过 %cd% 加以引用。 dir 列文件名 例子 结果 dir /p c:\windows 即列出一屏的目录 attrib 设置文件属性 del 删除命令 例子 结果 del d:\abc.txt 删除abc.txt文件 del /p d:\123\*.* /P 删除每一个文件之前提示确认。 del /s e:\test\123\*.* /S 从所有子目录删除指定文件。确认一次删除一个目录的文件。 del /s /q e:\test\123*.* 安静模式,删除目录和子目录下所有文件 copy 只能复制文件,不能复制文件夹。 例子 结果 copy e:\test\123\123.txt e:\test\ 复制的源文件 文件复制的目标路径 copy e:\test

Regular expressions in findstr

风格不统一 提交于 2019-11-28 06:16:41
I'm doing a little string validation with findstr and its /r flag to allow for regular expressions. In particular I'd like to validate integers. The regex ^[0-9][0-9]*$ worked fine for non-negative numbers but since I now support negative numbers as well I tried ^([1-9][0-9]*|0|-[1-9][0-9]*)$ for either positive or negative integers or zero. The regex works fine theoretically . I tested it in PowerShell and it matches what I want. However, with findstr /r /c:"^([1-9][0-9]*|0|-[1-9][0-9]*)$" it doesn't. While I know that findstr doesn't have the most advanced regex support (even below Notepad++

Findstr always fails to find hash string in text file

余生颓废 提交于 2019-11-28 01:46:38
I'm trying to replace a certain .jar file if the MD5 hash of the file changes. I've written a small PowerShell script to do the hashing of the file and the .ps1 script is run through a batch file. After PowerShell prints the hash into 1.txt I want the batch script to check the text file for the correct hash and if the hash is different it will overwrite the file with the old version. The replacing of the file is not yet implemented but will be once the findstr issue is resolved. @echo off setlocal EnableDelayedExpansion :a powershell.exe -ExecutionPolicy ByPass -file powershellmd5.ps1 findstr