V2EX = way to explore
V2EX 是一个关于分享和探索的地方
Sign Up Now
For Existing Member  Sign In
Distributions
Ubuntu
Fedora
CentOS
中文资源站
网易开源镜像站
fsckzy
V2EX  ›  Linux

如何利用 shell 脚本或者 sed, awk 之类的,随机打乱文本文件?

  •  
  •   fsckzy · Feb 26, 2016 · 3587 views
    This topic created in 3713 days ago, the information mentioned may be changed or developed.
    一个文本文件,要随机打乱里面的内容
    5 replies    2016-03-02 10:14:16 +08:00
    ayang23
        1
    ayang23  
       Feb 26, 2016
    sort -R
    chemzqm
        2
    chemzqm  
       Feb 26, 2016
    man shuf
    ngn999
        3
    ngn999  
       Feb 26, 2016 via iPhone
    cat file.txt | perl -nale '$h{$_}++; END{map
    {print} keys %h}'
    tchekai704
        4
    tchekai704  
       Feb 27, 2016
    自行搜索: Shell 脚本实现乱序排列文件内容的多种方法(洗牌问题)
    yiyiwa
        5
    yiyiwa  
       Mar 2, 2016
    只是行?
    awk '{a[$0]}END{for(i in a)print i}' file
    数组是无序的
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   3798 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 38ms · UTC 04:39 · PVG 12:39 · LAX 21:39 · JFK 00:39
    ♥ Do have faith in what you're doing.