MyTetra Share
Делитесь знаниями!
О, смотри-ка какое хорошее место. Дайте два!
randomly shuffling files in bash
Раздел: root - Linux - Console - bash

get_some_lines | sort -R


get_some_lines | shuf

if you don't have shuf or your sort doesn't know the -R, you can use for example:

standard perl:

get_some_lines | perl -MList::Util=shuffle -e 'print shuffle<STDIN>'

or BASH script

get_some_lines | while IFS= read -r line


printf "%06d %s\n" $RANDOM "$line"

done | sort -n | cut -c8-

the same numbered sort trick with awk

get_some_lines | awk 'BEGIN{srand()}{printf "%06d %s\n", rand()*1000000, $0;}' | sort -n | cut -c8-

In your case, the get_some_lines should be the:

cat file1 file2 #or cat file2 file1 :)

MyTetra Share v.0.44
Яндекс индекс цитирования