[CentOS] Conversion of text in shell
Marko A. Jennings
markobiz at bluegargoyle.comFri Oct 12 21:15:38 UTC 2007
- Previous message: [CentOS] Conversion of text in shell
- Next message: [CentOS] Conversion of text in shell
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
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.
- Previous message: [CentOS] Conversion of text in shell
- Next message: [CentOS] Conversion of text in shell
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
More information about the CentOS mailing list