Search code examples
windowspowershellescapingack

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


I cannot figure out how to escape the '<' character, 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.

Solution

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

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