I just had an interesting thing to solve. I had a comma separated list of text strings that I wanted to sort alphabetically (I'm sure someone is going to point out a better solution for this now).<div><br></div><div>The steps I thought up were quite simple.</div>
<div>Convert to a list (separate values by line breaks) in <font class="Apple-style-span" face="'courier new', monospace">test.txt</font></div><div>Sort the list</div><div>Convert back to comma separated</div><div>
<br></div><div>My initial thought for the converting from comma separated values to a list was sed (replace characters):</div><div><div><font class="Apple-style-span" face="'courier new', monospace">cat test.txt | sed 's/,/\</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">/g'</font></div></div><div><br></div><div>Not pretty to look at.</div><div><br></div><div>Pipe this into <font class="Apple-style-span" face="'courier new', monospace">sort</font></div>
<div><br></div><div>then try and use sed to put it back.</div><div><div><font class="Apple-style-span" face="'courier new', monospace">cat test.txt | sed 's/,/\</font></div><div><font class="Apple-style-span" face="'courier new', monospace">/g' | sort | sed 's/\</font></div>
<div><font class="Apple-style-span" face="'courier new', monospace">/,/g'</font></div></div><div><br></div><div>Not pretty and it didn't work... A quick look up on google later and I'm introduced to tr, translate (its an interesting and useful unix tool)</div>
<div><font class="Apple-style-span" face="'courier new', monospace">cat test.txt | tr ',' '\n' | sort | tr '\n' ','</font></div><div><br></div><div>While tr: <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?tr+1">http://unixhelp.ed.ac.uk/CGI/man-cgi?tr+1</a> has lots of specific uses and this isn't exactly what it was designed for. The syntax on an individual character replace is simpler.</div>
<div><br></div>