Windows command for cutting columns from a text

时光总嘲笑我的痴心妄想 提交于 2019-11-30 19:43:31

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

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

missing awk
@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).

If you had perl installed:

perl.exe -na  -e "print qq{$F[4]\n}" < myfile.txt
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!