Distributions
› Ubuntu
› Fedora
› CentOS
中文资源站
› 网易开源镜像站
fsckzy
V2EX  ›  Linux

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

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