Awk-Exponential Values


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Awk-Exponential Values
# 1  
Old 09-17-2014
Awk-Exponential Values

Hi Friends,

My input
Code:
Gene1 4.14887050399078e-49
Gene2 5.39999891278828e-10
Gene 2.22108326729483e-11

How do I change the above exponential values to normal values?

Thanks
# 2  
Old 09-17-2014
Hello Jacobs.smith,

Not sure but trying if following may help you.

Code:
awk -F" |-" '{$2=sprintf("%.5f", $2)} {print $2}'  Input_file

Output will be as follows.

Code:
4.14887
5.40000
2.22108

EDIT: Sorry I have misunderstood the request so kindly don't refer this above solution.

Thanks,
R. Singh

Last edited by RavinderSingh13; 09-17-2014 at 01:28 PM..
This User Gave Thanks to RavinderSingh13 For This Post:
# 3  
Old 09-17-2014
I guess the exponential values are considered "abnormal"...
with the variable width/precision:
Code:
awk '{n=split($2,a,"[.e-]");$2=sprintf("%.*f\n", length(a[2])+a[n],$2)}1'  myFile

This User Gave Thanks to vgersh99 For This Post:
# 4  
Old 09-17-2014
Or else fixed width like this

Code:
$ awk '{$2+=0}1' CONVFMT="%0.64f" file

Code:
$ awk '{n=split($2,A,"[.e-]"); fmt="%0."length(A[2])+A[n]"f"; $2=sprintf(fmt,$2)}1' file

--
I see vgersh99 posted already...
@vgersh99 : I think you have to remove \n Smilie

Last edited by Akshay Hegde; 09-17-2014 at 01:33 PM..
This User Gave Thanks to Akshay Hegde For This Post:
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

awk file to read values from Db2 table replacing hard coded values

Hi, I want to replace a chain of if-else statement in an old AWK file with values from Db2 table or CSV file. The part of code is below... if (start_new_rec=="true"){ exclude_user="false"; user=toupper($6); match(user, "XXXXX."); if (RSTART ==2 ) { ... (9 Replies)
Discussion started by: asandy1234
9 Replies

2. Shell Programming and Scripting

AWK - Avoid exponential value

I'm using the following command, but how can I avoid printing exponential value (highlighted):- awk ' BEGIN { OFS=FS="|" } { if(NF>4) $10=int(((3.77*$11)/100 + $11)); } { print } ' infile CR|20121022|105|GSM|N|SAN|00122|SAN|75082|6.03929e+06|5819880|5794769|25111... (7 Replies)
Discussion started by: Yoda
7 Replies

3. Shell Programming and Scripting

Exponential issues

I have the below awk command to search a row and find the line number. It returns the value in exponential. I understand we can use the print "%.0f\n" to convert the exponential. I wanted to have this in my awk command. Can anyone advise bnd=`awk '/^GS/{p=NR}$0~"^ABC.*\\*"k{f=1}/^GE/&&f{print... (3 Replies)
Discussion started by: Muthuraj K
3 Replies

4. Shell Programming and Scripting

The awk subtraction giving exponential values.Please help resolve it

Hi friends, I have a file list1 which has these 2 columns like 616449 0 434453 1 2151083 0 2226536 0 2132382 0 2136814 0 I have to put the result of col1 -col2 into another file list2 linewise. e.g. It gives the below result if use the below code: awk '{ print $1 - $2 }' list1 >... (2 Replies)
Discussion started by: kunwar
2 Replies

5. Shell Programming and Scripting

Turning off exponential notation in awk

I have various numbers that I'm printing out from a statistical summary script. I'd like it to stop using exponential format. Of course, I can use printf with 'd' and 'f' and various parameters to specify a format, but then it has other undesirable effects, like tacking on extra 0's or truncating... (0 Replies)
Discussion started by: treesloth
0 Replies

6. Shell Programming and Scripting

AWK: read values from file1; search for values in file2

I have read another post about this issue and am wondering how to adapt it to my own, much simpler, issue. I have a file of user IDs like so: 333333 321321 546465 ...etc I need to take each number and use it to print records wherein the 5th field matches the user ID pulled from the... (2 Replies)
Discussion started by: Bubnoff
2 Replies

7. Shell Programming and Scripting

How to pick values from column based on key values by usin AWK

Dear Guyz:) I have 2 different input files like this. I would like to pick the values or letters from the inputfile2 based on inputfile1 keys (A,F,N,X,Z). I have done similar task by using awk but in that case the inputfiles are similar like in inputfile2 (all keys in 1st column and values in... (16 Replies)
Discussion started by: repinementer
16 Replies

8. Shell Programming and Scripting

Converting Exponential values to decimals

Hi, I have a number of large (500Mb) txt files in the following format: 8.05475136E+05 9.69428147E+05 1 14 2968.00 3419.00 59.00 59 3.4028235E+38 2 w99-100 8.05464719E+05 9.69435064E+05 1 14 2968.03 3418.50 60.00 60 3.4028235E+38 2 w99-100 8.05454301E+05 ... (4 Replies)
Discussion started by: barrypitts
4 Replies

9. Shell Programming and Scripting

Conversion of Exponential to numeric in awk- not correct output

Hi All, I have 1 million records file. Using awk, I am counting the number of records. But as the number is huge, after crossing a number, awk is displaying it in exponential format. At the end, I need to verify this count given by awk with expected count. But as it is in exponential format,... (3 Replies)
Discussion started by: ssunda6
3 Replies

10. Shell Programming and Scripting

Converting exponential values

Hi. Is there a way to convert a value outputted as(for example): 4.14486e+06 into a regular format: 4144860 I suppose in plain english i want to move the decimal point 6 places to the right. please??? (2 Replies)
Discussion started by: rleebife
2 Replies
Login or Register to Ask a Question