Board logo

标题: [文本处理] 【求助】windows用findstr或grep匹配出文档的第一列数据 [打印本页]

作者: 572105002    时间: 2020-4-17 14:22     标题: 【求助】windows用findstr或grep匹配出文档的第一列数据

G:\下载\grep>type g:\zabbix\conf\tes.txt|findstr "::"
100011::4
100012::0
100013::2
100014::0
以::做分割把第一列数据输出命令怎么写,用findstr或者grep都可以,求大佬指点
作者: wujunkai    时间: 2020-4-17 16:14

回复 1# 572105002


    for /F "delims" 不行嘛?
作者: Batcher    时间: 2020-4-17 18:36

回复 1# 572105002
  1. @echo off
  2. for /f "delims=:" %%i in ('type "tes.txt" ^| findstr "::"') do (
  3.     echo,%%i
  4. )
  5. pause
复制代码

作者: Batcher    时间: 2020-4-17 18:38

回复 1# 572105002


D:\Test>grep -Po ".*(?=:" tes.txt
100011
100012
100013
100014




欢迎光临 批处理之家 (http://bbs.bathome.net/) Powered by Discuz! 7.2