LuJason
V2EX  ›  问与答

请问: 100w 个文件怎样快速合并到一起

  •  
  •   LuJason · Jul 8, 2020 · 1626 views
    This topic created in 2138 days ago, the information mentioned may be changed or developed.

    每个文件倒是不大,几百到几千行不等

    尝试使用cat 但是内存会溢出

    笨办法倒是有,一个一个文件去读取...但好像也不快

    所以有啥奇淫技巧吗

    5 replies    2020-07-09 09:44:36 +08:00
    jimliang
        1
    jimliang  
       Jul 8, 2020
    cat file1 file2 > file
    F281M6Dh8DXpD1g2
        2
    F281M6Dh8DXpD1g2  
       Jul 8, 2020
    格式一样么
    格式一样放在一个目录下面用 spark 完事
    jimliang
        3
    jimliang  
       Jul 8, 2020
    不好意思,刚刚没看到已经尝试用过 cat 了
    xupefei
        4
    xupefei  
       Jul 8, 2020
    fish:

    for f in (ls)
    cat $f >> combined.txt
    end

    bash/zsh 同理。
    deppindeepin
        5
    deppindeepin  
       Jul 9, 2020
    何谓"快速"?指的是快速实现还是快速合并(合并速度)?
    如果是前者的吧,拿一个自己熟悉的脚本语言搞一下岂不是分分钟么
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   2863 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 42ms · UTC 12:25 · PVG 20:25 · LAX 05:25 · JFK 08:25
    ♥ Do have faith in what you're doing.