[FZH] 请教文本处理问题

Mike Manilone crtmike at gmx.us
Sun Apr 28 05:48:04 UTC 2013


不合題目要求,因爲不是vim/sed/awk - -

Common Lisp 版:

(with-open-file (stream1 #p"D:/1.txt" :direction :input)
(with-open-file (stream2 #p"D:/2.txt" :direction :input)
     (loop for line1 = (read-line stream1 nil)
         for line2 = (read-line stream2 nil)
         until (or (null line1) (null line2))
         do (format t "~a~a~%" line1 line2))))

因爲要手動在每行上迭代,所以有點長。。

可以先全讀出來再在每行上循環應該比較簡單 :-D

于 2013-4-27 8:21, 牛博恩 写道:
> 有两个文本文件,1.txt 和2.txt
> 我想把2.txt的内容附加到1.txt的每一行后面
> 比如1.txt内容是
> 1
> 2
> 3
> 4
>
> 2.txt的内容和1.txt相同,最后希望得到的效果是
> 11
> 22
> 33
> 44
> ----------------------
> 求用vim或者sed,awk这样的工具的解决办法
> --
> Fedora中文郵件列表:https://admin.fedoraproject.org/mailman/listinfo/chinese



More information about the Chinese mailing list