我在 linux 中有一些文件。例如 2,我需要将文件改组到一个文件中。
例如
$cat file1
line 1
line 2
line 3
line 4
line 5
line 6
line 7
line 8
和
$cat file2
linea one
linea two
linea three
linea four
linea five
linea six
linea seven
linea eight
然后我洗牌这两个文件,我可以获得类似的东西:
linea eight
line 4
linea five
line 1
linea three
line 8
linea seven
line 5
linea two
linea one
line 2
linea four
line 7
linea six
line 1
line 6
最佳答案
你应该使用 shuf
命令 =)
cat file1 file2 | shuf
或者使用 Perl:
cat file1 file2 | perl -MList::Util=shuffle -wne 'print shuffle <>;'
关于linux - 在 Linux/Bash 中随机改组行,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/17578873/