To get the precision you want it is a little more complicated than that; we still need to split the mantissa and exponent out of $5 and have bc perform arithmetic that you were doing in your script. For example: If we expand on MadeInGermany's awk script adding some error checking and using bc to get the desired precision we get something like:
and we expand density.mesh_index to contain several duplicates of lines you showed us in message #8 in this thread to expand it to 800 lines (and add 40 empty lines for fun) and modify a few of the exponents on the numbers in field 5 to use E+004 and E+005 instead of E-004 and E-005 (to test out the logic of converting values with positive and negative exponents) it produces the output:
I also tried a slightly modified version of your script (to get rid of the diagnostics from bc induced by processing empty lines):
which when invoked with the operands density.mesh_index 1 840 to process all of the lines in the same file produces the output:
Running the modified copy of your script with bash as the interpreter 10 times took from 22.94 to 23.76 seconds of wall clock time each. Changing the modified copy of your script to use ksh instead of bash produced the same results with execution times from 22.25 to 23.27 seconds each.
Using ksh to process the same data using the script I based on MadeInGermany's code 10 times took from .02 to .03 seconds each. And modifying that script to use bash instead of ksh took .02 to .04 seconds each. All of these tests were run on a 4 year old MacBook Pro running OS X version 10.7.5.
Hopefully, this streamlined script will cut your processing time for your 160 files from the 1.13 years you estimated to a something closer to 1 day.
In case you're having trouble following what the awk script is doing to $5 as it passes work to bc, an abbreviated version of what awk writes through the pipe to bc when given the input you showed us in message #8 in this thread follows:
These 2 Users Gave Thanks to Don Cragun For This Post:
I want to grep a range of numbers in a log file. My log file looks like this:
20050807070609Z;blah blah
That is a combination of yr,month,date,hours,minutes,seconds.
I want to search in the log file events that happened between a particular time.
like between 20050807070000 to 20050822070000... (1 Reply)
Suppose u have a file like
1 30
ABCSAAHSNJQJALBALMKAANKAMLAMALK
4562676268836826826868268468368282972982
2863923792102370179372012792701739729291
31 60... (8 Replies)
Ok, so this is a small part of a script I wrote to build disk groups using VXVM. The only problem is that I am limited to a count of 8 maximum. If I want more, I will have to add more lines of "if" statements. How can I accomplish the same thing, in a few lines, but not be limited in the max... (13 Replies)
Hi im new to unix and need to find a way to grep the top 5 numbers in a file and put them into another file. For example my file looks like this
abcdef 50000
abcdef 45000
abcdef 40000
abcdef 35000
abcdef 30000
abcdef 25000
abcdef 20000
abcdef 15000
abcdef 10000
and so on...
How can... (1 Reply)
Howdy experts,
We have some ranges of number which belongs to particual group as below.
GroupNo StartRange EndRange
Group0125 935300 935399
Group2006 935400 935476
937430 937459
Group0324 935477 935549
... (6 Replies)
Hello,
I have a column where there are values from 1 to 150.
I want to get the frequency of values in the following ranges:
1-5
6-10
11-15
....
....
....
146-150
How can I do this in a for loop?
Thanks,
Guss (1 Reply)
Dear Friends,
I want to know how to grep for the lines that has a number between given range(start and end).
I have tried the following sed command.
sed -n -e '/20030101011442/,/20030101035519/p'
However this requires both start and end to be part of the content being grepped. However... (4 Replies)
Hi
I am getting an argument which specifies the range of numbers. eg: 7-15
Is there a way that i can easily (avoiding loop) print the range of number between and including the specified above.
The above example should translate to 7,8,9,10,11,12,13,14,15 (3 Replies)