Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
在命令提示符下,以下两行给出相同的输出,我想知道它们之间的用法差异。谢谢。
>nul dir
dir >nul
没有区别,它们重定向相同数量的输出。您可以通过多种方式组合输入和输出重定向运算符:> out.txt command < in.txt或< in.txt command > out.txt.
> out.txt command < in.txt
< in.txt command > out.txt
如评论中所述,如果某些内容包含数字 1 或 2,您必须小心,您不想%something%>out.txt扩展为...2>out.txt,您可以使用空格或将其放在命令的其余部分之前。
%something%>out.txt
...2>out.txt