用于从文本中剪切列的 Windows 命令

发布于 2024-10-07 17:41:04 字数 693 浏览 0 评论 0原文

文件中存储以下内容:

chrome.exe                   512 Console                 0     73,780 K
chrome.exe                   800 Console                 0     11,052 K
chrome.exe                  1488 Console                 0     92,720 K
chrome.exe                  1600 Console                 0     32,344 K
chrome.exe                  2240 Console                 0     35,132 K
chrome.exe                  2360 Console                 0     21,276 K
chrome.exe                  3524 Console                 0     66,732 K
chrome.exe                  3924 Console                 0     23,524 K

有没有办法使用 Windows 命令行提取第 5 列?

类似于 UNIX cut 命令。

The following content is stored in a file:

chrome.exe                   512 Console                 0     73,780 K
chrome.exe                   800 Console                 0     11,052 K
chrome.exe                  1488 Console                 0     92,720 K
chrome.exe                  1600 Console                 0     32,344 K
chrome.exe                  2240 Console                 0     35,132 K
chrome.exe                  2360 Console                 0     21,276 K
chrome.exe                  3524 Console                 0     66,732 K
chrome.exe                  3924 Console                 0     23,524 K

Is there a way to extract the 5th column with the Windows command line?

Something like the UNIX cut command.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(5

孤檠 2024-10-14 17:41:04

在变量中使用双 %

for /f "tokens=5 delims= " %%i in (file.txt) DO echo %%i

Use double % in variable

for /f "tokens=5 delims= " %%i in (file.txt) DO echo %%i
扮仙女 2024-10-14 17:41:04

如果您熟悉 GNU 剪切实用程序,那么最好使用 Win32 端口:

http: //gnuwin32.sourceforge.net/packages/coreutils.htm

If you're familiar with the GNU cut utility, you might be better off using the Win32 port:

http://gnuwin32.sourceforge.net/packages/coreutils.htm

口干舌燥 2024-10-14 17:41:04
@ECHO OFF

for /F "tokens=2-4" %%a in (%1) DO ( echo %%a %%b %%c )

我花了很长时间才发现 %%a %%b %%c .... [%%z] 引用文本文件中的后续列。
因此,此示例将从文本文件 (%1) 中提取第二、第三和第四列(单词)。

@ECHO OFF

for /F "tokens=2-4" %%a in (%1) DO ( echo %%a %%b %%c )

took me a long time to find out that %%a %%b %%c .... [%%z] refer to subsequent colums in a text file.
So this example will extract the 2nd, 3rd and 4th column (word) from a textfile (%1).

情魔剑神 2024-10-14 17:41:04

您还可以使用 mobaxterm (https://mobaxterm.mobatek.net/) 作为 ssh 客户端,然后打开本地终端。它包含unix命令,如cut、grap、wc等

You can also use mobaxterm (https://mobaxterm.mobatek.net/) a ssh client, and open a local terminal. It contain unix comands like cut, grap, wc ,etc

吻安 2024-10-14 17:41:04

如果您安装了 perl:

perl.exe -na  -e "print qq{$F[4]\n}" < myfile.txt

If you had perl installed:

perl.exe -na  -e "print qq{$F[4]\n}" < myfile.txt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文