将“<”或“>”写入 .txt 文件
Write "<" or ">" to a .txt file
我想将“<”或“>”符号写入文本文件。
有一个我试过的例子:
echo echo. >file2.txt>file1.txt
但这不起作用。
我想要的是使用以下文本使批处理文件 make file2.txt:
echo. >file1.txt
有人知道怎么做吗?
使用 ^
转义 <
或 >
。注意要实际重定向到一个文件,您需要一个额外的重定向运算符。
这是一个使用 >
的示例 - 同样的解决方案适用于 <
(以及 %
)。
echo .^> > file.txt
所以要在名为redir.txt:
的文本文件中得到你想要的结果(包含echo. file2.txt > file1.txt
的文本文件)
echo echo. file2.txt ^> file1.txt > redir.txt
最终结果在redir.txt:
c:\temp>type redir.txt
echo. file2.txt > file.txt
这是DOS吗?看这里:
http://www.robvanderwoude.com/escapechars.php
您必须使用插入符号“^”。回声 ^>
PHP 使用\
http://php.net/manual/en/regexp.reference.escape.php
是Unix吗?使用引号。
我想将“<”或“>”符号写入文本文件。 有一个我试过的例子:
echo echo. >file2.txt>file1.txt
但这不起作用。 我想要的是使用以下文本使批处理文件 make file2.txt:
echo. >file1.txt
有人知道怎么做吗?
使用 ^
转义 <
或 >
。注意要实际重定向到一个文件,您需要一个额外的重定向运算符。
这是一个使用 >
的示例 - 同样的解决方案适用于 <
(以及 %
)。
echo .^> > file.txt
所以要在名为redir.txt:
的文本文件中得到你想要的结果(包含echo. file2.txt > file1.txt
的文本文件)
echo echo. file2.txt ^> file1.txt > redir.txt
最终结果在redir.txt:
c:\temp>type redir.txt
echo. file2.txt > file.txt
这是DOS吗?看这里:
http://www.robvanderwoude.com/escapechars.php
您必须使用插入符号“^”。回声 ^>
PHP 使用\
http://php.net/manual/en/regexp.reference.escape.php
是Unix吗?使用引号。