[CentOS] Conversion of text in shell

Fri Oct 12 21:37:42 UTC 2007
roland hellström <arwinkahalarak at hotmail.com>

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

----------------------------------------> Subject: RE: [CentOS] Conversion of text in shell> Date: Fri, 12 Oct 2007 17:29:13 -0400> From: rwalker at medallion.com> To: centos at centos.org>> Marko A. Jennings wrote:>>>> On Fri, October 12, 2007 4:54 pm, roland hellström wrote:>>>>>> Hi! I want to convert the lines>>> 1.1,3.19e-4>>> 1.2,3.05e-3>>> 10.5,9.14e8>>> (as example)>>>>>> to>>>>>> 1,1 & $3,19 \cdot 10^{-4}$\\>>> etc.. from one file and save these in a new file>>> Rly lost here except I know I should use regexp and MAYBE>> sed somehow :)>>> Thx for any help>>>> Assuming that you have those lines in a file called>> numbers.txt, you can>> execute the following (all on one line):>>>> cat numbers.txt | tr '.,e' ',^^' | awk -F^ '{printf("%s & $%s \\cdot>> 10^{%s}$\\\\\n", $1, $2, $3);}'>>>> The output will be:>>>> 1,1 & $3,19 \cdot 10^{-4}$\\>> 1,2 & $3,05 \cdot 10^{-3}$\\>> 10,5 & $9,14 \cdot 10^{8}$\\>>>> Not the most elegant solution, but it works. I hope this is>> what you were>> looking for.>> This has the smackings of a CS student trying to get answers to> a homework project. The output looks meaningless and the input> looks just as meaningless.>> If so, then you'll never learn how to do it unless you make> your brain think it out itself...>> -Ross>>>> ______________________________________________________________________> 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!