[CentOS] Conversion of text in shell

Fri Oct 12 23:09:32 UTC 2007
roland hellström <arwinkahalarak at hotmail.com>

OK! I finally figured out the solution for all you people out the eager to hear it!!!
it was infact very very similar to the last line I sent... this is it
sed 's/\([^\.]*\).\([^,]*\),\([^\.]*\).\([^e]*\)e\(.*\)/\1,\2 \& $\3,\4 \\cdot 10^{\5}$\\\\/'

omg I feel so h4xx0r figuring that out myself lol
Thx for the help all :)

----------------------------------------> Subject: RE: [CentOS] Conversion of text in shell> Date: Fri, 12 Oct 2007 17:57:54 -0400> From: rwalker at medallion.com> To: centos at centos.org>> roland hellström wrote:>>>> Indeed this is a chalmers student. The purpose of asking>> though is to learn it, because I find it very hard to learn>> without seeing an example of it.>> Thx for the reply it seemed to work well :) Although it would>> be interesting to see if this could be done with the sed>> command somehow?>> Thx in advance>>>> Then let me help you think it out:>> Given a text file with this data:> 1.1,3.19e-4> 1.2,3.05e-3> 10.5,9.14e-8 <- I'm guessing this was suppose to be scientific not>> Convert to a text file:> 1,1 & $3,19 \cdot 10^{-4}$\\> 1,2 & $3,05 \cdot 10^{-3}$\\> 10,5 & $9,14 \cdot 10^{-8}$\\>> Look for the pattern match ups:> 1.1,3.19e-4> 1,1 & $3,19 \cdot 10^{-4}$\\>> 1.2,3.05e-3> 1,2 & $3,05 \cdot 10^{-3}$\\>> 10.5,9.14e-8> 10,5 & $9,14 \cdot 10^{-8}$\\>> It looks like:> 1) decimals converted to commas> 2) commas converted to " & "> 3) "e" converted to " \cdot 10^{<>}$\\"> 4) <> substituted for whatever comes after the "e">> Now if you convert decimals to commas BEFORE you convert> commas to " & " then you will have garbage, so you need> to convert commas to " & " first, then decimals to> commas, then apply the conversion w/ substituion.>> Substitution is handled with the \(\) operator like such:>> echo "this is a test" | sed -e 's/\(.*\) is a \(.*\)/\2 is NOT a \1/'>> Will output: "test is NOT a this">> Can be done in 3 steps, sed can take multiple operations> if you separate them with ;>> >> PS Fix your mail client to post in plain text and put> your reply text at the bottom of the email instead of> the top.>> ______________________________________________________________________> This e-mail, and any attachments thereto, is intended only for use by> the addressee(s) named herein and may contain legally privileged> and/or confidential information. If you are not the intended recipient> of this e-mail, you are hereby notified that any dissemination,> distribution or copying of this e-mail, and any attachments thereto,> is strictly prohibited. If you have received this e-mail in error,> please immediately notify the sender and permanently delete the> original and any copy or printout thereof.>> _______________________________________________> CentOS mailing list> CentOS at centos.org> http://lists.centos.org/mailman/listinfo/centos

Express yourself instantly with MSN Messenger! Download today it's FREE!