tags:

views:

76

answers:

2

Create a file called Valid[File].txt and stick some text in it. Start powershell and go to the directory.

gc Valid[File].txt
should display the value in the file. It returns blank. If you use tab auto-completion it escapes the name:
gc 'Valid[File].txt'
but still returns nothing.

How do I reference files with brackets in their names?

A: 

You probably need to enclose it in quotation marks: gc "Valid[File].txt"

Jeff Hubbard
+4  A: 

Turns out the key was -literalpath. For details see this technet article

Brian Adams
Ouch. It's easier to install Cygwin!
Jonathan Leffler
@jonathan It may be easier, but on the Windows platform, PowerShell has more opportunities and "power".
Steven Murawski
There are known bugs with handling of brackets in filenames. It'll be fixed in v2.
halr9000