如何在名称中引用带括号的文件

时间:2021-12-24 01:59:02

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

创建一个名为Valid [File] .txt的文件,并在其中粘贴一些文本。启动powershell并转到该目录。

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?

如何在名称中引用带括号的文件?

2 个解决方案

#1


7  

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

原来关键是-literalpath。有关详细信息,请参阅此technet文章

#2


0  

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

您可能需要将其括在引号中:gc“Valid [File] .txt”

#1


7  

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

原来关键是-literalpath。有关详细信息,请参阅此technet文章

#2


0  

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

您可能需要将其括在引号中:gc“Valid [File] .txt”