home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #16 / NN_1992_16.iso / spool / comp / unix / question / 9650 < prev    next >
Encoding:
Internet Message Format  |  1992-07-31  |  1.7 KB

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