Board logo

标题: [文本处理] [已解决]请问批处理如何让相同开头的字排在同一行? [打印本页]

作者: 每天几分    时间: 2022-8-28 14:06     标题: [已解决]请问批处理如何让相同开头的字排在同一行?

有个txt的码表文件:

牌        thma
我        taj
生        tg
自        th
……
牌        thmf
我        tae
生        te
自        t
……

请问如何实现如下排列,谢谢!

牌        thma                牌        thmf
我        taj        我        tae
生        tg        生        te
自        th        自        t
……
作者: flashercs    时间: 2022-8-28 15:01

脚本保存ANSI编码
  1. @echo off
  2. cd /d "%~dp0"
  3. set codefile=码表.txt
  4. powershell -c "(gc -literal $env:codefile -read 0)|Group-Object -Property @{e={if($_ -match '\S+'){$Matches[0]}else{''}}}|foreach{$_.Group -join ([char]9)}"
  5. pause
复制代码





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