home *** CD-ROM | disk | FTP | other *** search
- Path: sparky!uunet!sun-barr!cs.utexas.edu!sdd.hp.com!swrinde!zaphod.mps.ohio-state.edu!news.acns.nwu.edu!nucsrl!ddsw1!dattier
- From: dattier@ddsw1.mcs.com (David W. Tamkin)
- Newsgroups: comp.unix.questions
- Subject: Re: Using sed to convert numbers (interesting)
- Message-ID: <1992Jul31.192133.9665@ddsw1.mcs.com>
- Date: 31 Jul 92 19:21:33 GMT
- References: <1992Jul31.121118.27783@news.acns.nwu.edu>
- Organization: Contributor Account at ddsw1, Chicago, Illinois 60657
- Lines: 26
- X-Disclaimer: Material posted in this article is the sole responsibility of
- the poster and does not represent MCSNet or the system owners.
-
- navarra@casbah.acns.nwu.edu (John Navarra) wrote in
- <1992Jul31.121118.27783@news.acns.nwu.edu>:
-
- | 1) for you sed gurus, I don't understand WHY my substitutions are working
- | for negative numbers.
-
- The part of the line outside the target string isn't changed. The s command
- says to change the part starting with the digit before the decimal point;
- anything farther leftward in the line (or for that matter, anything to the
- right of the exponent) remains unaltered and the substitution is done in the
- middle.
-
- | How does sed know to put the '-' back at the beginning of the line?
-
- You didn't tell it to take the minus sign away, so it's still there at the
- end.
-
- | What I need is a variable which will scan what the value of 'XX' is
- | in E[+-]XX and for numbers > 1 (E+XX) , write out 'XX' number of '[0-9]'
- | strings in the pattern, and for numbers < 1 (E-XX), write out XX-1 zeroes
- | in the replacement string. Any suggestions on how to do this?
-
- sed cannot do that. It's perl time.
-
- David W. Tamkin Box 59297 Northtown Station, Illinois 60659-0297
- dattier@ddsw1.mcs.com CompuServe: 73720,1570 MCI Mail: 426-1818
-