我有一个 txt 文件,其中包含一些行,例如:
a
b
c
f
e
f
1
2
3
4
5
6
现在我想要随机行并将其打印到另一个 txt 文件,例如:
f
6
e
1
and so on...
任何人都可以帮助我吗? 我是 bash 脚本的新手
最佳答案
您可以使用 shuf
(GNU coreutils 的一部分)。
shuf inputfile > outfile
例如:
$ seq 10 | shuf
7
5
8
3
9
4
10
1
6
2
关于linux - 如何用bash随机化txt中的行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20881104/