Sponsored Content
Full Discussion: Round up the decimals
Top Forums Shell Programming and Scripting Round up the decimals Post 302706199 by rajeevm on Wednesday 26th of September 2012 09:58:18 AM
Old 09-26-2012
Thanks Pamu

That code for one but its not working for the second

which is I need to split the number of records into 75% and 25 % so i did this for 75 % just like you mentioned

but i implemented the same for 25 % like below
Code:
25%=`awk -v VAR="$TOTAL_RECORDS" 'BEGIN {printf "%.0f",(VAR * 25 /100) }'`

the result is 187 but instead of 188 as the result would be 749*25/100=187.25 in that I would be missing one record when I will these records to a file

I appreciate your help.

Thanks
rajeevm

Last edited by Franklin52; 09-26-2012 at 11:11 AM.. Reason: Please use code tags for data and code samples
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

handle decimals

Hi All, How we can handle decimals in (Float) in UNIX. a=73 b=5 c=`expr a / b` i am getting 14 but i need full 14.6 . Can any one help me pls? (1 Reply)
Discussion started by: subin_bala
1 Replies

2. Shell Programming and Scripting

Bourne and decimals??

I need to get 15% of the variable exer1 to be added to other exercises so far, i've got exer1=$1 aver=`expr $exer \* .15` but i keep getting an error that an integer value was expected. Is there anyway around this? (1 Reply)
Discussion started by: kdyzsa
1 Replies

3. Shell Programming and Scripting

removing and rounding up decimals

Hi Experts, I have a command that gives me the output as below root@ckpgpay11core> cat sara | awk '{ sum += $1} ; END { print sum }' | awk {'print $1/90'} 8.88889 how do i remove the decimal spaces so that the figure will round itself to 9? Thanks. (3 Replies)
Discussion started by: aismann
3 Replies

4. Shell Programming and Scripting

convert Regular decimals to Packed decimals

Hi, I am trying to find if there is a way to convert regular decimal values to Paced decimal values. I tried to find a c program but I could get a Packed converted to regular decimal not the other way round. If not unix please let me know if any other progrimming language I can use to do... (2 Replies)
Discussion started by: mgirinath
2 Replies

5. Shell Programming and Scripting

How to multiple decimals in linux

How to multiple decimals in Linux? When I do it like this i get an error message echo "$((1 * 1.1))" -bash: 1 * 1.1: syntax error in expression (error token is ".1") (4 Replies)
Discussion started by: 3junior
4 Replies

6. Shell Programming and Scripting

Decimals in TCSH

Hello, I want to run a loop with non-integer values (which I know I can't) so I've created a loop of integers and divided it by 10. However, these values are always rounded down to 1 significant figure. How do I get the script to keep and use the decimal value? My script is as follows #... (1 Reply)
Discussion started by: DFr0st
1 Replies

7. UNIX for Dummies Questions & Answers

Regarding Decimals in Cshell

Hello... I am new to unix and I am wondering if in a C-shell script , Are we supposed to use only whole numbers........ for example..if a program needs to calculate the average of some numbers........ @ avg = (($1 +$2 + $3)/3)) is returning a whole number.........How can a decimal be achieved... (1 Reply)
Discussion started by: ravindra22
1 Replies

8. Shell Programming and Scripting

Getting date in seconds with decimals

I am trying to get date to display decimal Desired output 1350386096256.12 I know this can be done with printf, but are not able to make it work. I have tested this and many otherprintf "%.2f" $(($(date +%s%N)/1000000)) (8 Replies)
Discussion started by: Jotne
8 Replies

9. Shell Programming and Scripting

Can expr deal with decimals?

Hello, Im trying to work on a small script for a formula converting temperatures, Celsius to fahrenheit. I have a formula, and it works.... it works every way I try it. But it keeps giving me the wrong results every time with expr. The formula for C to F would be: divide by 5, multiply by... (12 Replies)
Discussion started by: hxdrummerxc
12 Replies

10. Programming

Decimals reading Python

Hello, i'm new in python. Consider that i have this function that read me some data from a serial : def GetData(): line = open(serialx).read() hash = line.find("#") when = line count = line # print when, count, line return (float(when), int(count)) it gives me the result... (2 Replies)
Discussion started by: Board27
2 Replies
UPSLOG(8)							    NUT Manual								 UPSLOG(8)

NAME
upslog - UPS status logger SYNOPSIS
upslog -h upslog [OPTIONS] DESCRIPTION
upslog is a daemon that will poll a UPS at periodic intervals, fetch the variables that interest you, format them, and write them to a file. The default format string includes variables that are supported by many common UPS models. See the description below to make your own. OPTIONS
-h Display the help message. -f format Monitor the UPS using this format string. Be sure to enclose format in quotes so your shell doesn't split it up. Valid escapes within this string are: %% Insert a single "%" %TIME format% Insert the time with strftime formatting %ETIME% Insert the number of seconds, ala time_t. This is now a 10 digit number. %HOST% insert the local hostname %UPSHOST% insert the host of the UPS being monitored %PID% insert the pid of upslog %VAR varname% insert the value of variable varname The default format string is: %TIME @Y@m@d @H@M@S% %VAR battery.charge% %VAR input.voltage% %VAR ups.load% [%VAR ups.status%] %VAR ups.temperature% %VAR input.frequency% -i interval Wait this many seconds between polls. This defaults to 30 seconds. If you require tighter timing, you should write your own logger using the upsclient(3) library. -l logfile Store the results in this file. You can use "-" for stdout, but upslog will remain in the foreground. -s ups Monitor this UPS. The format for this option is upsname[@hostname[:port]]. The default hostname is "localhost". -u username If started as root, upsmon will setuid(2) to the user id associated with username for security. If username is not defined, it will use the value that was compiled into the program. This defaults to "nobody", which is less than ideal. SERVICE DELAYS
The interval value is merely the number given to sleep(3) after running through the format string. Therefore, a query will actually take slightly longer than the interval, depending on the speed of your system. LOG ROTATION
upslog writes its PID to upslog.pid, and will reopen the log file if you send it a SIGHUP. This allows it to keep running when the log is rotated by an external program. SEE ALSO
Server: upsd(8) Clients: upsc(8), upscmd(8), upsrw(8), upsmon(8) Internet resources: The NUT (Network UPS Tools) home page: http://www.networkupstools.org/ Network UPS Tools 05/21/2012 UPSLOG(8)
All times are GMT -4. The time now is 11:22 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy