3

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.
Community
  • 1
  • 1
Tom
  • 543
  • 1
  • 9
  • 19

3 Answers3

5

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

Select-String '<' *.*

## or
dir -r | Select-String '<'
JasonMArcher
  • 14,195
  • 22
  • 56
  • 52
  • I did not know that feature existed. Thanks for notifying me of it. The second command you suggested has solved my problem. – Tom Aug 01 '11 at 01:45
  • Is there a good resource for performance comparison between this tool and Unix ones (ack, ag, ripgrep, grep) ? – Lorah Attkins Oct 11 '20 at 12:43
0

Escape character in PowerShell is backtick:

PS C:\xampp\htdocs> ack `<
stej
  • 28,745
  • 11
  • 71
  • 104
  • The problem is not PowerShell, the problem is on the ack or shell side. – JasonMArcher Jul 29 '11 at 16:24
  • When I type "ack \`<" I get the error "The syntax of the command is incorrect". Stej, can you confirm that you have run the command 'ack `<' on your system and that it works for you? If so I'll agree with JasonMArcher. – Tom Jul 31 '11 at 23:26
-1

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.

Moses
  • 9,033
  • 5
  • 44
  • 67
  • I have edited the question to show the output when attempting 'ack <'. – Tom Jul 29 '11 at 07:17
  • @Tom I've updated my answer. Hopefully you will find it useful. – Moses Jul 29 '11 at 07:26
  • Thanks for you help Moses, but when I type "ack '<' --output '$i' -h" I get the error "The system cannot find the file specified." – Tom Jul 31 '11 at 23:26