Board logo

标题: [文本处理] [已解决]批处理怎么分别添加后缀 [打印本页]

作者: kingming    时间: 2015-10-4 17:13     标题: [已解决]批处理怎么分别添加后缀

本帖最后由 kingming 于 2015-10-5 09:23 编辑

假设有两个文本一个a.txt
1
2
3
第二个文本b.txt
a
b
c
如何将它们整理为
1a
1b
1c
2a
2b
2c
3a
3b
3c
并且输出到c.txt
作者: bailong360    时间: 2015-10-4 18:32

  1. @echo off
  2. setlocal enabledelayedexpansion
  3. ::CODE BY zhonghua @bbs.bathome.net
  4. (for /f "delims=" %%i in (a.txt) do (
  5.     set _n=
  6.     set /p _n=
  7.     echo;%%i!_n!
  8. ))<b.txt >c.txt
复制代码
如果行数相同的话
作者: /zhqsystem/zhq    时间: 2015-10-4 22:14

  1. @echo off
  2. (for /f "delims=" %%i in (a.txt) do (
  3. for /f "delims=" %%j in (b.txt) do (
  4.   echo=%%i%%j
  5. )
  6. ))>3.txt
  7. pause
复制代码

作者: CrLf    时间: 2015-10-4 22:32

回复 2# bailong360


    赶脚楼主好像不是这意思
作者: bailong360    时间: 2015-10-4 22:53

回复 4# CrLf
......就放在那里警示坛友吧:回答问题前务必要看清LZ在问什么...
作者: CrLf    时间: 2015-10-5 08:23

回复 5# bailong360


    http://bbs.bathome.net/viewthread.php?tid=37541
作者: wankoilz    时间: 2015-10-7 00:32

本帖最后由 wankoilz 于 2015-10-7 00:36 编辑

练手:
  1. #&cls&@gawk -f %0 a.txt b.txt&pause&exit
  2. {
  3. if(FILENAME=="a.txt"){col1[$0]=1}else{col2[$0]=1}
  4. }
  5. END {
  6. for(x in col1){for(y in col2){OFS="";print x,y}}
  7. }
复制代码





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