[CentOS] Conversion of text in shell

Fri Oct 12 21:29:13 UTC 2007
Ross S. W. Walker <rwalker at medallion.com>

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.