Randomly shuffling lines in Linux / Bash

前端 未结 8 2110
囚心锁ツ
囚心锁ツ 2020-12-01 04:16

I have some files in linux. For example 2 and i need shuffling the files in one file.

For example

$cat file1
line 1
line 2
line 3
line 4
line 5
line          


        
8条回答
  •  北荒
    北荒 (楼主)
    2020-12-01 04:49

    I would use shuf too.

    another option, gnu sort has:

       -R, --random-sort
              sort by random hash of keys
    

    you could try:

    cat file1 file2|sort -R
    

提交回复
热议问题