Rom's Rants
Free-Roaming Hostility From A QA/Developer Perspective.
April 18, 2013
HOWTO: Get a random sampling of lines from a text file in bash
Let's say you needed to get 150 lines at random from a text file and you were running Linux.
The solution involves a command I wasn't aware of until today...
shuf
.
The command:
shuf file-to-sample.txt | head -n 150
shuf scrambles all the lines in the file; head pulls the set number of lines for you.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment