RE: Conversion of text in shell

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]



And btw it is not a homework project, it is simply some excercises to help us learn :)
----------------------------------------> Subject: RE:  Conversion of text in shell> Date: Fri, 12 Oct 2007 17:29:13 -0400> From: rwalker@xxxxxxxxxxxxx> To: centos@xxxxxxxxxx>> 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@xxxxxxxxxx> http://lists.centos.org/mailman/listinfo/centos

_________________________________________________________________
Express yourself instantly with MSN Messenger! Download today it's FREE!
http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


[Index of Archives]     [CentOS]     [CentOS Announce]     [CentOS Development]     [CentOS ARM Devel]     [CentOS Docs]     [CentOS Virtualization]     [Carrier Grade Linux]     [Linux Media]     [Asterisk]     [DCCP]     [Netdev]     [Xorg]     [Linux USB]
  Powered by Linux