muuyouzhi

shuf命令可以随机提取一个文本文件的不同行,输出到文件或者标准输出中。

 

shuf

用法: shuf [选项]... [文件]
 或者:  shuf -e [选项]... [参数]...
 或者:  shuf -i LO-HI [选项]...
Write a random permutation of the input lines to standard output.

如果没有指定文件,或者文件为"-",则从标准输入读取。

必选参数对长短选项同时适用。
  -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
  -r, --repeat              output lines can be repeated
  -z, --zero-terminated     line delimiter is NUL, not newline
      --help        显示此帮助信息并退出
      --version        显示版本信息并退出

 

例如:提取一个input.txt中的随机20行

 

shuf input.txt -n 20 -o output.txt

 

分类:

技术点:

相关文章:

  • 2021-08-26
  • 2021-08-05
  • 2022-12-23
  • 2021-08-23
  • 2023-04-11
  • 2022-12-23
  • 2022-12-23
  • 2021-05-10
猜你喜欢
  • 2021-11-17
  • 2021-05-29
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
  • 2021-12-03
  • 2022-12-23
相关资源
相似解决方案