10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Heyas
Trying to calculate the total size of a file by reading its bitrate.
Code snippet:
fs_expected() { #
# Returns the expected filesize in bytes
#
pr_str() {
ff=$(cat $TMP.info)
d="${ff#*bitrate: }"
echo "${d%%,*}" | $AWK '{print $1}' | head -n 1
}
t_BYTERATE=$((... (9 Replies)
Discussion started by: sea
9 Replies
2. Shell Programming and Scripting
Hi guys,
could someone throw some light on the following behaviour of printf (I'll start with info about the system and the tool/shell/interpreter versions)?:
$ uname -a
Linux linux-86if.site 3.1.0-1.2-desktop #1 SMP PREEMPT Thu Nov 3 14:45:45 UTC 2011 (187dde0) x86_64 x86_64 x86_64... (9 Replies)
Discussion started by: elixir_sinari
9 Replies
3. Shell Programming and Scripting
I have some calculation in my script which is similar to the below example . I find that sometimes when using large decimal digits, the output gets automatically rounded off and it is affecting the program. I am not able to understand what is happening here..
awk '{
a=6.32498922
a1=6.324... (5 Replies)
Discussion started by: wanderingmind16
5 Replies
4. Shell Programming and Scripting
Hi,
I have a dataset say
1 2 3 4
5 5 6 7
6 7 8 9
I was wondering if there is a way to add another column with the following style...
1 2 3 4 xyz_1
5 5 6 7 xyz_2
6 7 8 9 xyz_3
It would be greatly appreciated if I can have an option of specifying what to write instead of xyz,... (8 Replies)
Discussion started by: jacobs.smith
8 Replies
5. Shell Programming and Scripting
I had a person bring an interesting problem to me that appears to involve some sort of rounding inside awk. I've verified this with awk and nawk on Solaris as well as with gawk 3.1.5 on a Linux box.
The original code fragment he brought me was thus:
for (index=0; index < 1; index=index+.1)
... (4 Replies)
Discussion started by: mmyer2
4 Replies
6. Shell Programming and Scripting
Hi Friends,
I am trying to round following number.
0.07435000
echo "0.07435000"|awk '{printf "%s\n",$1*100}'|awk '{printf "%.2f\n",$1}'
It returns: 7.435
It should return: 7.44
Any suggestion please?
Thanks,
Prashant (2 Replies)
Discussion started by: ppat7046
2 Replies
7. UNIX for Dummies Questions & Answers
Hello
I am getting this very annoying issue in awk:
awk '{a=12825;b=a*1.25; print b}' test
16031.2
Thing is the multiplication result is wrong... Result should be 16031.25.
I think the issue only happens on bigger numbers.
What can I do to get passed this?
Thanks by advance (3 Replies)
Discussion started by: Indalecio
3 Replies
8. Shell Programming and Scripting
suppose u have a file
AAG
AAG
GYG
HYH
GTG
AAG
AAG
HYH
GYG
HUH
JUJ
JUJ
AAG
so output shud have
AAG = 5
GYG=2
HYH=2
HUH=1JUJ=2 (3 Replies)
Discussion started by: cdfd123
3 Replies
9. Shell Programming and Scripting
Hello again.
I'm trying to use BC to calculate some numbers in a shell script.
I want to have the numbers rounded off to 1 decimal place.
for example:
initsize=1566720
zipsize=4733
I'm trying to get the ratio between them. the equation is:
(($initsize-$zipsize)/$initsize)*100
so... (3 Replies)
Discussion started by: noodlesoup
3 Replies
10. Shell Programming and Scripting
i would like to enter (user input) a bunch of numbers seperated by space:
10 15 20 25
and use awk to print out any lines in a file that have matching numbers
so output is:
22 44 66 55 (10) 77 (20)
(numbers 10 and 20 matched for example)
is this possible in awk . im using gawk for... (5 Replies)
Discussion started by: tanku
5 Replies
ROUND(3) Linux Programmer's Manual ROUND(3)
NAME
round, roundf, roundl - round to nearest integer, away from zero
SYNOPSIS
#include <math.h>
double round(double x);
float roundf(float x);
long double roundl(long double x);
DESCRIPTION
These functions round x to the nearest integer, but round halfway cases away from zero (regardless of the current rounding direction),
instead of to the nearest even integer like rint().
RETURN VALUE
The rounded integer value. If x is integral or infinite, x itself is returned.
ERRORS
No errors other than EDOM and ERANGE can occur. If x is NaN, then NaN is returned and errno may be set to EDOM.
NOTES
POSIX 1003.1-2001 contains text about overflow (which might set errno to ERANGE, or raise an exception). In practice, the result cannot
overflow on any current machine, so this error-handling stuff is just nonsense. (More precisely, overflow can happen only when the maximum
value of the exponent is smaller than the number of mantissa bits. For the IEEE-754 standard 32-bit and 64-bit floating point numbers the
maximum value of the exponent is 128 (resp. 1024), and the number of mantissa bits is 24 (resp. 53).)
CONFORMING TO
C99.
SEE ALSO
ceil(3), floor(3), lround(3), nearbyint(3), rint(3), trunc(3)
2001-05-31 ROUND(3)