开发者

How to search for '<' in files using ack in powershell in windows?

开发者 https://www.devze.com 2023-03-23 22:24 出处:网络
I cannot figure out how to escape the \'<\' characte开发者_JAVA百科r, and I am confused by the \'The system cannot find the file specified\' error.Can anyone help?

I cannot figure out how to escape the '<' characte开发者_JAVA百科r, and I am confused by the 'The system cannot find the file specified' error. Can anyone help?

I am using ack in powershell in Windows XP.

The question ack-grep: chars escaping is very similar to mine, but the solutions offered and accepted for that question do not work for me.

PS C:\xampp\htdocs> ack abcd
<works as expected>
PS C:\xampp\htdocs> ack <
The redirection operator '<' is not supported yet.
At line:1 char:5
+ ack < <<<<
PS C:\xampp\htdocs> ack \<
The syntax of the command is incorrect.
PS C:\xampp\htdocs> ack '<'
The syntax of the command is incorrect.
PS C:\xampp\htdocs> ack '\<'
The syntax of the command is incorrect.
PS C:\xampp\htdocs> ack [<]
The system cannot find the file specified.
PS C:\xampp\htdocs> ack '[<]'
The system cannot find the file specified.
PS C:\xampp\htdocs> ack '[\<]'
The system cannot find the file specified.
PS C:\xampp\htdocs> ack \Q<\E
The system cannot find the file specified.


Is there any reason you don't want to use PowerShell's regex search?

Select-String '<' *.*

## or
dir -r | Select-String '<'


Escape character in PowerShell is backtick:

PS C:\xampp\htdocs> ack `<


Do you mean awk? If so, then all you have to do is: $awk '/</ filename'

Since I don't have ack installed I can't verify 100%, but I would try this code out:

ack  '<' --output '$1' -h

If that doesn't work, then I would recommend reading through the man ack and the ack --help pages.

0

精彩评论

暂无评论...
验证码 换一张
取 消