Re: Conversion of text in shell

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



Title: Re: Conversion of text in shell

As it turns out this was a CS class exercise in using sed and regex.

And excuse me, but you ARE using regular expressions in your example...

-Ross


-----Original Message-----
From: centos-bounces@xxxxxxxxxx <centos-bounces@xxxxxxxxxx>
To: CentOS mailing list <centos@xxxxxxxxxx>
Sent: Mon Oct 15 17:07:11 2007
Subject: Re: Conversion of text in shell

Ross S. W. Walker wrote:
> Ross S. W. Walker wrote:
>> roland hellström wrote:
>>> 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 :)
>> I am surprised you got it all in 1 regex, I was aiming more for:
>>
>> sed 's/,/ & /;s/\./,/;s/\(.*\)e\(.*\)/\1 \\cdot 10^{\2}/'
>
> whoops, I made a mistake:
>
> sed 's/,/ \& /;s/\./,/g;s/\(.*\)e\(.*\)/\1 \\cdot 10^{\2}\$\\\\/'
>
> You need the 'g' option in the second substitute to perform a
> global, and of course the proper cdot _expression_.
>

you don't need regex:

sed \
        -e '/^ *$/d' \
        -e 's/,/ \& $/' \
        -e 's/\./,/g'  \
        -e 's/e/ \\cdot 10^{/' -e s'/$/}$\\\\/' \
                /path/to/input/file

now, the exercice is to read the input file directly with LaTeX using
TeX macros instead of converting it.

_______________________________________________
CentOS mailing list
CentOS@xxxxxxxxxx
http://lists.centos.org/mailman/listinfo/centos


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

[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