how do I randomize the order of words in a .txt file? I don't know any bash and don't know any good resources thanks to all
            Asked
            
        
        
            Active
            
        
            Viewed 1,470 times
        
    1
            
            
        - 
                    1possible duplicate of [How can I randomize the lines in a file using a standard tools on Redhat Linux](http://stackoverflow.com/questions/886237/how-can-i-randomize-the-lines-in-a-file-using-a-standard-tools-on-redhat-linux) – tripleee Mar 20 '14 at 18:42
2 Answers
3
            If there's one word per line, you can use shuf yourfile to output them in random order, or 
shuf yourfile > tmpfile && mv tmpfile yourfile
to write the shuffled contents back into yourfile.
 
    
    
        that other guy
        
- 116,971
- 11
- 170
- 194
- 
                    You can use `tr ' ' '\n' < yourfile | shuf | tr '\n' ' '` to shuffle words in a file and put all the shuffled words on one line. – that other guy Feb 11 '13 at 06:33
1
            
            
        If there is more than one word per line, you can use this Perl one-liner:
 perl -MList::Util -e '$/=""; print join " ", List::Util::shuffle split /\s/, <>' <in.txt >out.txt
If you don't like that output file will be in single line, you can change it be one word per line: simply replace join " " with join "\n".
 
    
    
        mvp
        
- 111,019
- 13
- 122
- 148
