用于从文本中剪切列的Windows命令
以下内容存储在文件中:用于从文本中剪切列的Windows命令,windows,command-line,data-manipulation,cut,Windows,Command Line,Data Manipulation,Cut,以下内容存储在文件中: 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
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
命令。如果您熟悉GNU cut实用程序,最好使用Win32端口:
如果已安装perl:
perl.exe -na -e "print qq{$F[4]\n}" < myfile.txt
perl.exe-na-e“打印qq{$F[4]\n}”
在变量中使用double%
for /f "tokens=5 delims= " %%i in (file.txt) DO echo %%i
我花了很长时间才发现%%a%%b%%c。。。。[%%z]
请参阅文本文件中的后续列。
因此,本例将从文本文件(%1)中提取第2、第3和第4列(word)。您也可以使用mobaxterm()作为ssh客户端,并打开本地终端。它包含unix命令,如cut、grap、wc等。。。这没用。我相信poster可以用任何语言编写代码来实现这一点,但这不是我要问的问题。同样,我发现它很容易使用,因为已经安装了许多unix命令。
@ECHO OFF
for /F "tokens=2-4" %%a in (%1) DO ( echo %%a %%b %%c )