Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
Using awk, and passing in a program with the -f option, taking a gigantic input file, and trying to generate a much smaller output file (party responsible for the extract does NOT have time to modify it to do this). There are numerous fields with extraneous zeroes on the output (ex: 6.000000000 vs. just 6 or 6.0). Issue is, when I try to use \. and match, say \.000000000 and replace with \.0, it STILL does an 'any-single-character' match on the period, and I CANNOT get it to work. Example: an input of 5000000000 would generate a 0. I've also tried using single-quotes as well. Seems like a bug, or maybe I'm just misunderstanding how this SHOULD work, but I've also scoured the web and still cannot find an answer for this. Also tried using gawk to no avail.
Any Tips? Was thinking of using decimal values to loop through the fields perhaps and outputting those, or using Perl, but I strongly fear those two alternatives would take much, much, longer.
Joe
All Your Base Are Belong to Us

Note: Using the gsub function. The code:
BEGIN{FS="\|"}
gsub("\|0.000000000\|","\|0\|");
gsub("\|0.000000000$","\|0");
gsub("\|.000000000$","\|0");
gsub("\|.000000000\|","\|0\|");
gsub("\.10000000\|","\.1\|");
gsub("\.20000000\|","\.2\|");
gsub("\.30000000\|","\.3\|");
gsub("\.40000000\|","\.4\|");
gsub("\.50000000\|","\.5\|");
gsub("\.60000000\|","\.6\|");
gsub("\.70000000\|","\.7\|");
gsub("\.80000000\|","\.8\|");
gsub("\.90000000\|","\.9\|");
gsub("\.000000000\|","\.0\|");
gsub("\.000000000\|","\.0\|");
gsub("\.00000000\|","\.0\|");
gsub("\.000000000","\.0");
print }
All Your Base Are Belong to Us

Scoured the web some more, used perl, and (a) It Works, and (b) Is far, far, faster than grep or sed.
Issue closed.
Joe
All Your Base Are Belong to Us

![]() |
emacs copy question
|
Comparison with differenc...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |