in

historyOfOneTextFile

historyOfOneTextFile | try-memes, random-memes, IT-memes, mac-memes, feature-memes | ProgrammerHumor.io
try-memes, random-memes, IT-memes, mac-memes, feature-memes | ProgrammerHumor.io

Content

2 Answers Active Oldest Votes 541 Use shuf with the -n option as shown below, to get N random lines: shuf -n N input output share morove this answer allow edited Jun 16 16 at 20:48 DAmainSFAATTITed 1,234 1 18 29 answered Feb 25 ’13 at 11:03 dogbane 226k 69 351 388 35 This should be the accepted answer. Wow, shuf is sooo fast. – picking 10000 random lines from a textile with 40000 lines is instant. Trying to use ‘sort -R’ took so long I just CTRL-C it – carpii Jul 3 ’15 at 20:10 2 1 If you just need a random set of lines, not in a random order, then shuf is very inefficient (for big file): better is to do reservoir sampling, as in this answer. – petrelharp Sep 6 ’15 at 23:24 neither shuf nor sort -R are available for mac OSX. any suggestions? – Tom Smith Oct 6 ’15 at 10:06 33 TomSmith On Mac OSX, if you are using Homebrew, you can get shuf or GNU sort by installing coreutils . More info here: apple.stackexchange.comquestions142860install-shuf-on-os-x – nofinator Oct 8 ’15 at 13:11 7 shuf is fantastic. I tried in on a 78 Billion line text file and it did the job in less than 1 minute. – Ash Jan 19 ’16 at 8:13 7 shuf is fantastic. I tried in on a 78 Billion line text file and it did the job in less than 1 minute. – Ash Jan 19 16 at 8:13 1 78 Billion line text file The WHAT