<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
		>
<channel>
	<title>Comments on: Bash one liner to randomize lines in file</title>
	<atom:link href="http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/feed/" rel="self" type="application/rss+xml" />
	<link>http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/</link>
	<description>Matt Michie&#039;s rants, raves, and thoughts</description>
	<lastBuildDate>Thu, 11 Feb 2010 00:36:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9</generator>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
		<item>
		<title>By: Jadu Saikia</title>
		<link>http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/comment-page-1/#comment-44961</link>
		<dc:creator>Jadu Saikia</dc:creator>
		<pubDate>Sun, 10 Jan 2010 13:33:44 +0000</pubDate>
		<guid isPermaLink="false">http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/#comment-44961</guid>
		<description>&#039;Shuf&#039; and &#039;rl&#039; are good options here. Here are two small tutorial on my blog:

rl:
http://unstableme.blogspot.com/2010/01/randomize-lines-using-linux-rl-command.html

shuf:
http://unstableme.blogspot.com/2009/10/linux-shuf-command-generate-random.html</description>
		<content:encoded><![CDATA[<p>&#8216;Shuf&#8217; and &#8216;rl&#8217; are good options here. Here are two small tutorial on my blog:</p>
<p>rl:<br />
<a href="http://unstableme.blogspot.com/2010/01/randomize-lines-using-linux-rl-command.html" rel="nofollow">http://unstableme.blogspot.com/2010/01/randomize-lines-using-linux-rl-command.html</a></p>
<p>shuf:<br />
<a href="http://unstableme.blogspot.com/2009/10/linux-shuf-command-generate-random.html" rel="nofollow">http://unstableme.blogspot.com/2009/10/linux-shuf-command-generate-random.html</a></p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Moses</title>
		<link>http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/comment-page-1/#comment-42492</link>
		<dc:creator>Moses</dc:creator>
		<pubDate>Tue, 10 Nov 2009 17:16:48 +0000</pubDate>
		<guid isPermaLink="false">http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/#comment-42492</guid>
		<description>&quot;why don&#039;t you use shuf?  Why not use sort -R?&quot;
If I had shuf, or if my local /bin/sort supported -R, I would use it.  But I don&#039;t, which is why I&#039;m using something fork-y in bash.

&quot;why don&#039;t you just get shuf?&quot;
Because I don&#039;t have root and/or gcc on every machine I touch.

HOWEVER, with what was mentioned above, I can make shuf:

echo -e &#039;#!/bin/bash&#039;&quot;\n&quot;&#039;while read -r LINE; do echo &quot;$RANDOM $LINE&quot;; done &#124;sort &#124;sed -r &#039;&quot;&#039;s/^[0-9]+ //&#039;&quot; &gt; ~/bin/shuf
chmod 0755 ~/bin/shuf

Now I can put  &#124;shuf  into my chains of pipes.</description>
		<content:encoded><![CDATA[<p>&#8220;why don&#8217;t you use shuf?  Why not use sort -R?&#8221;<br />
If I had shuf, or if my local /bin/sort supported -R, I would use it.  But I don&#8217;t, which is why I&#8217;m using something fork-y in bash.</p>
<p>&#8220;why don&#8217;t you just get shuf?&#8221;<br />
Because I don&#8217;t have root and/or gcc on every machine I touch.</p>
<p>HOWEVER, with what was mentioned above, I can make shuf:</p>
<p>echo -e &#8216;#!/bin/bash&#8217;&#8221;\n&#8221;&#8216;while read -r LINE; do echo &#8220;$RANDOM $LINE&#8221;; done |sort |sed -r &#8216;&#8221;&#8217;s/^[0-9]+ //&#8217;&#8221; &gt; ~/bin/shuf<br />
chmod 0755 ~/bin/shuf</p>
<p>Now I can put  |shuf  into my chains of pipes.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: manoflinux</title>
		<link>http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/comment-page-1/#comment-40480</link>
		<dc:creator>manoflinux</dc:creator>
		<pubDate>Wed, 23 Sep 2009 20:01:35 +0000</pubDate>
		<guid isPermaLink="false">http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/#comment-40480</guid>
		<description>this actually works for me. its simpler and uses colrm which rocks.

for i in `cat mapslist.txt`; do echo `printf &quot;%08d&quot; $RANDOM` $i; done &#124; sort &#124; colrm 1 10 &gt;mapslist.txt.rand; mv mapslist.txt mapslist.old; mv mapslist.txt.rand mapslist.txt;</description>
		<content:encoded><![CDATA[<p>this actually works for me. its simpler and uses colrm which rocks.</p>
<p>for i in `cat mapslist.txt`; do echo `printf &#8220;%08d&#8221; $RANDOM` $i; done | sort | colrm 1 10 &gt;mapslist.txt.rand; mv mapslist.txt mapslist.old; mv mapslist.txt.rand mapslist.txt;</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Arthur</title>
		<link>http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/comment-page-1/#comment-40326</link>
		<dc:creator>Arthur</dc:creator>
		<pubDate>Sun, 20 Sep 2009 11:33:23 +0000</pubDate>
		<guid isPermaLink="false">http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/#comment-40326</guid>
		<description>sort -R will only work if the lines are unique.  If there are duplicate lines, sort -R will put them next to each other.  

shuf on the other hand will sufficiently randomize a list, including NOT putting duplicate lines next to each other.</description>
		<content:encoded><![CDATA[<p>sort -R will only work if the lines are unique.  If there are duplicate lines, sort -R will put them next to each other.  </p>
<p>shuf on the other hand will sufficiently randomize a list, including NOT putting duplicate lines next to each other.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: swordfish</title>
		<link>http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/comment-page-1/#comment-38730</link>
		<dc:creator>swordfish</dc:creator>
		<pubDate>Mon, 03 Aug 2009 01:30:33 +0000</pubDate>
		<guid isPermaLink="false">http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/#comment-38730</guid>
		<description>none of these worked for me. i found the solution on a far away google result : (be careful despite this is the first google result , the formatting sucks and copy-paste may give errors)

awk &#039;BEGIN {srand()} {print int(rand()*1000000) &quot;\t&quot; $0}&#039; file &#124; sort -n &#124; cut -f 2-</description>
		<content:encoded><![CDATA[<p>none of these worked for me. i found the solution on a far away google result : (be careful despite this is the first google result , the formatting sucks and copy-paste may give errors)</p>
<p>awk &#8216;BEGIN {srand()} {print int(rand()*1000000) &#8220;\t&#8221; $0}&#8217; file | sort -n | cut -f 2-</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: gabriellllo</title>
		<link>http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/comment-page-1/#comment-38167</link>
		<dc:creator>gabriellllo</dc:creator>
		<pubDate>Mon, 06 Jul 2009 23:08:53 +0000</pubDate>
		<guid isPermaLink="false">http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/#comment-38167</guid>
		<description>Great tip!

Since I had numbers in my file, I used awk instead of sed, since I found it easier:
for i in `cat list_to_randomize.txt`; do echo &quot;$RANDOM $i&quot;; done &#124; sort &#124; awk &#039;{print $2}&#039; &gt; randomized_list.txt

Thanks a lot for this page!

G.</description>
		<content:encoded><![CDATA[<p>Great tip!</p>
<p>Since I had numbers in my file, I used awk instead of sed, since I found it easier:<br />
for i in `cat list_to_randomize.txt`; do echo &#8220;$RANDOM $i&#8221;; done | sort | awk &#8216;{print $2}&#8217; &gt; randomized_list.txt</p>
<p>Thanks a lot for this page!</p>
<p>G.</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Boris Abramov</title>
		<link>http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/comment-page-1/#comment-38020</link>
		<dc:creator>Boris Abramov</dc:creator>
		<pubDate>Thu, 25 Jun 2009 12:17:39 +0000</pubDate>
		<guid isPermaLink="false">http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/#comment-38020</guid>
		<description>sort -R
:)</description>
		<content:encoded><![CDATA[<p>sort -R<br />
 <img src='http://hivearchive.com/wordpress/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
	</item>
	<item>
		<title>By: bart</title>
		<link>http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/comment-page-1/#comment-37652</link>
		<dc:creator>bart</dc:creator>
		<pubDate>Fri, 29 May 2009 01:31:39 +0000</pubDate>
		<guid isPermaLink="false">http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/#comment-37652</guid>
		<description>How about:
awk &#039;BEGIN{srand()}{print rand(),$0}&#039; SOMEFILE &#124; sort -n &#124; cut -d &#039; &#039; -f2-</description>
		<content:encoded><![CDATA[<p>How about:<br />
awk &#8216;BEGIN{srand()}{print rand(),$0}&#8217; SOMEFILE | sort -n | cut -d &#8216; &#8216; -f2-</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: (Pseudo) aleatori en BASH &#124; L’home dibuixat</title>
		<link>http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/comment-page-1/#comment-37339</link>
		<dc:creator>(Pseudo) aleatori en BASH &#124; L’home dibuixat</dc:creator>
		<pubDate>Tue, 12 May 2009 17:01:53 +0000</pubDate>
		<guid isPermaLink="false">http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/#comment-37339</guid>
		<description>[...] té una funció $RANDOM que genera un nombre pseudo-aleatori en cada [...]</description>
		<content:encoded><![CDATA[<p>[...] té una funció $RANDOM que genera un nombre pseudo-aleatori en cada [...]</p>
]]></content:encoded>
	</item>
	<item>
		<title>By: Dougal</title>
		<link>http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/comment-page-1/#comment-37091</link>
		<dc:creator>Dougal</dc:creator>
		<pubDate>Sun, 03 May 2009 20:14:08 +0000</pubDate>
		<guid isPermaLink="false">http://hivearchive.com/2007/10/18/bash-one-liner-to-randomize-lines-in-file/#comment-37091</guid>
		<description>My previous comment got screwed up by the formatting...

First part: &quot;while read i ; do echo “$RANDOM $i”; done randorder.txt&quot;</description>
		<content:encoded><![CDATA[<p>My previous comment got screwed up by the formatting&#8230;</p>
<p>First part: &#8220;while read i ; do echo “$RANDOM $i”; done randorder.txt&#8221;</p>
]]></content:encoded>
	</item>
</channel>
</rss>
