zoukankan      html  css  js  c++  java
  • shuf命令简单用法

    shuf命令简单用法

    背景:需要将一个文件的内容按照行进行打乱顺序;需要从一个大文件中随机获取多少行的内容,除了python脚本处理以外,一些shell命令也可以更快捷的做到

    shuf命令详解

    bash-4.1$ shuf --help
    Usage: shuf [OPTION]... [FILE]
      or:  shuf -e [OPTION]... [ARG]...
      or:  shuf -i LO-HI [OPTION]...
    Write a random permutation of the input lines to standard output.
    
    Mandatory arguments to long options are mandatory for short options too.
      -e, --echo                treat each ARG as an input line
      -i, --input-range=LO-HI   treat each number LO through HI as an input line
      -n, --head-count=COUNT    output at most COUNT lines
      -o, --output=FILE         write result to FILE instead of standard output
          --random-source=FILE  get random bytes from FILE
      -z, --zero-terminated     end lines with 0 byte, not newline
          --help     display this help and exit
          --version  output version information and exit
    
    With no FILE, or when FILE is -, read standard input.
    
    Report shuf bugs to bug-coreutils@gnu.org
    GNU coreutils home page: <http://www.gnu.org/software/coreutils/>
    General help using GNU software: <http://www.gnu.org/gethelp/>
    For complete documentation, run: info coreutils 'shuf invocation'
    
    # 例1:将一个文件顺序打乱输出到另一个文件
    shuf a.txt > b.txt
    shuf a.txt -o b.txt  # 以文件格式输出到b
    
    # 例2:将一个文件中的数据随机获取50条数据存到另一个文件中
    shuf a.txt -o b.txt -n 30
    

    本文来自博客园,作者:alisleepy,转载请注明原文链接:https://www.cnblogs.com/alisleepy/p/15534701.html

  • 相关阅读:
    十进制,二进制,八进制,十六进制中的相互转换
    oracle中dual表的使用
    弹出窗口
    oracle中的函数
    [导入]几种所见所得的在线编辑器
    操作字符串
    设计模式初认识
    创建型模式之简单工厂模式
    MySQL批量检查表的脚本
    中英文单位对照
  • 原文地址:https://www.cnblogs.com/alisleepy/p/15534701.html
Copyright © 2011-2022 走看看