当`tee` 在 Windows 上不可用时,如何将 ipconfig 输出保存到文本文件?

Mik*_*sta 8 windows file-transfer cmd.exe

我想将 ipconfig /all 保存到文本文件。我在 Windows 10 上。当我在 cmd 中尝试此操作时

ipconfig /all | tee file.txt
Run Code Online (Sandbox Code Playgroud)

我有

'tee' is not recognized as an internal or external command,operable program or batch file.
Run Code Online (Sandbox Code Playgroud)

什么是 Windows 替代品tee

Gre*_*g W 51

尝试重定向。而不是| tee,使用> output.txt例如

ipconfig /all > output.txt
Run Code Online (Sandbox Code Playgroud)

  • 问题标题明确指出“当 TEE 不可用时,如何将 IPCONFIG 输出保存到文本文件”。除了对 tee 命令本身的引用之外,问题标题和正文中都没有提到将内容同时显示到屏幕上。 (10认同)

Cia*_*zie 19

ipconfig /all >>logfile.txt 2>>&1

>>logfile.txt 2>>&1将两个输出流和错误流重定向到将要创建并保存在当前目录下一个名为LOGFILE.TXT。如果该目录中存在现有的 logfile.txt,它会将输出附加到它的末尾。


mvw*_*mvw 8

如果您安装MSYS2,您可以使用

$ ipconfig -all | tee file.txt
Run Code Online (Sandbox Code Playgroud)

请注意,/all必须写为-all.

就我而言,我得到:

$ head file.txt

Windows-IP-Konfiguration

   Hostname  . . . . . . . . . . . . : Death-Star
   [..]
Run Code Online (Sandbox Code Playgroud)

  • 虽然这不是一个糟糕的答案,但将 MSYS2 放在您的路径中会产生令人惊讶的后果。 (4认同)
  • 不需要msys2。`powershell -command "ipconfig /all | tee output.txt"` 会在你使用 cmd 时工作 (2认同)

归档时间:

查看次数:

14884 次

最近记录:

6 年,4 月 前