Convert e+ to number


 
Thread Tools Search this Thread
Top Forums Shell Programming and Scripting Convert e+ to number
# 1  
Old 07-02-2010
Convert e+ to number

Hi,

I am using awk to get particular dates in seconds and the output am getting is like 1.28071e+09.

How can I convert it to number format.

Can anyone help me out?

Thanks in advance..!
# 2  
Old 07-02-2010
Post code you are using, that is producing that output.
# 3  
Old 07-02-2010
Am using the following line code in awk,

secs1=((year1 - 1970)*365.25+(month1*30.5)+day1)*24*60*60;
# 4  
Old 07-02-2010
In bash:
Code:
printf "%10.0f\n" 1.28071e+09

# 5  
Old 07-02-2010
Quote:
Originally Posted by KenJackson
In bash:
Code:
printf "%10.0f\n" 1.28071e+09

Thanks a lot for your valuable quick response.

One more doubt.

Can I use 'printf' in any unix env as I don't have much idea of printf in unix.

The OS which I am using is HP-UX.
# 6  
Old 07-02-2010
Code:
# echo " (`printf "%.7s\n" 1.28071e+09`) * 1000000000 / 1" | bc
1280710000

# 7  
Old 07-02-2010
Quote:
Originally Posted by Kattoor
...
Can I use 'printf' in any unix env as I don't have much idea of printf in unix.

The OS which I am using is HP-UX.
You don't have to use the printf function of your OS shell.
You can use printf within awk itself, especially if you are doing all your calculations in an awk script.

Code:
$
$ awk 'BEGIN {x = 1.28071e+09; printf("%10.0f\n", x)}'
1280710000
$
$

As a side note, popular shells like KSH and Bash provide the printf function. So if your Unix environment has these shells, then you should be able to use printf.
Otherwise, you may want to check the man page.

tyler_durden
Login or Register to Ask a Question

Previous Thread | Next Thread

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Convert floating point to a number

Hello Guys, I have a floating point number 1.14475E+15 I want to convert this number in to full number (Integer or Big integer). I tried couple of functions it did not work. When I use INT=${FLOAT/.*} I am getting value as 1. I don't want a truncated value #!/bin/bash #... (9 Replies)
Discussion started by: skatpally
9 Replies

2. Shell Programming and Scripting

Convert a String to a Number

I read in two numbers from a user but the number is a string. #!/bin/bash read -p "Enter first number: " num1 read -p "Enter second number: " num2 I know you can use the the "expr" or "bc" command to automatically convert the string to a number then add them together. But I don't want to add... (10 Replies)
Discussion started by: Loc
10 Replies

3. Shell Programming and Scripting

Convert string number to a integer

I have data as below "ROWS merge process complete. thousand rows changed" I need to get a variable assigned the value of 1000. I mean convert the string thousand to 1000. Any help or pointer. Please use CODE tags as required by forum rules! (6 Replies)
Discussion started by: dsravanam
6 Replies

4. Shell Programming and Scripting

Convert number

friends as I can convert this value to number in this example it is well but can vary the value does not help me cut from a nesecito espefifica opsiocn get zero CantCabe = 00023 Cant = 23 CantPntCabe = 0000000000000034 CantPnt = 34 if && ; then echo... (3 Replies)
Discussion started by: tricampeon81
3 Replies

5. Shell Programming and Scripting

Convert UNIX rights in a number in a sh script

Hello, i'm trying to write a script sh to convert the rights of a folder or file in a number. Explain: ls -l = rwxrwxrwx so i must display 777. Do you known where i can find so convert script Thanks Use code tags, thanks. (11 Replies)
Discussion started by: steiner
11 Replies

6. Shell Programming and Scripting

How to convert number to english?

Hi gurus, I have a weird requirement. I need to convert the number to english lecture. I have 1.2 ....19 numbers I need to convert to first second third fourth, fifth, sixth... Is there any way convert it using unix command? thanks in advance. (8 Replies)
Discussion started by: ken6503
8 Replies

7. Shell Programming and Scripting

How to convert multiple number ranges into sequence?

Looking for a simple way to convert ranges to a numerical sequence that would assign the original value of the range to the individual numbers that are on the range. Thank you given data 13196-13199 0 13200 4 13201 10 13202-13207 3 13208-13210 7 desired... (3 Replies)
Discussion started by: jcue25
3 Replies

8. Shell Programming and Scripting

need script to convert number in hexadecimal

hi , i need a script to convert number into hexadecimal base for example: 237=>ED it s very important for me thank you in advance for you help (5 Replies)
Discussion started by: mips
5 Replies

9. Shell Programming and Scripting

Convert ip address to ip number

I want to make a script to read a list of ip addresses from a file then convert those ip addresses to ip number. ip number is made by removing the dots then transfer to a number , so the ip number transfered to binary then to decimal which will represents the ip number 0 : 4294967295 Also I... (17 Replies)
Discussion started by: moutaz1983
17 Replies

10. Shell Programming and Scripting

C Shell Script to convert a number into minutes

Could anyone tell me how to write a C shell script according to the following requirement. Write a C shell script convertmin which will read in a number, thought of as representing minutes, and print out the number of hours/minutes it represents so: Note: you are required to check exception... (1 Reply)
Discussion started by: Ringo
1 Replies
Login or Register to Ask a Question