我正在使用一个程序,该程序使用 type
命令将文件内容通过管道传输到另一个程序,如下所示:
type test.txt | (another program)
这个命令在我的主程序中是硬编码的。问题是 type
命令在正斜杠方面有问题:
E:\babak\git\bin>type e:/babak/git/bin/test.txt
The syntax of the command is incorrect.
有没有一种方法可以用名为 type
的自定义应用程序覆盖 cmd 内部 type
,它支持正斜杠,所以如果有人调用 type
在 cmd 中,调用自定义 type
应用程序?
最佳答案
您可以使用 doskey 覆盖 command.com 中的内部命令,例如在 win7 上
c:\> date
The current date is: Mon 09/18/2017
Enter the new date: (mm-dd-yy)
c:\> @doskey date=c:\cygwin\bin\date.exe $*
c:\> @doskey echo=c:\cygwin\bin\echo.exe $*
c:\> date +%Y-%m-%d
2017-09-18
关于windows - 覆盖 Windows cmd 内部命令,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13321506/