公告
财富商城
积分规则
提问
发文
2020-01-26 13:09发布
唯我独甜
In a Bash script, I want to pick out N random lines from input file and output to another file.
How can this be done?
Sort the file randomly and pick first 100 lines:
100
$ sort -R input | head -n 100 >output
Use shuf with the -n option as shown below, to get N random lines:
shuf
-n
N
shuf -n N input > output
最多设置5个标签!
Sort the file randomly and pick first
100
lines:Use
shuf
with the-n
option as shown below, to getN
random lines: