09-13-2004
bc calculate problem
Hi ,
this is the first time i use bc to calculate and i would have decimal result , i use the following :
toto=400;scale=1 echo $toto / 1000|bc
scale to adjust the numbers after the command would have in this case 0.4 as result and i wonder why i have always 0 as result.
Somebody can help ?
thanks
Christian
10 More Discussions You Might Find Interesting
1. Shell Programming and Scripting
Hi all
I have 3 three files like:
file1:
1|100
2|200
3|300
4|400
5|500
file2:
1|200
2|200
3|600
4|800
file3:
1|300
2|100 (5 Replies)
Discussion started by: koti_rama
5 Replies
2. Shell Programming and Scripting
I have 2 variables in my shell scripts in which i am using awk and calculating 2 files and getting 2 different variable called in_total and out_total. I want to subtract one variable from another so plz tell me how i can do that.
Example is:
cat in_file | awk -F: '{
in_total += $1 * 86400... (3 Replies)
Discussion started by: krishna_sicsr
3 Replies
3. Shell Programming and Scripting
Is there any awk command to calculate P Value ?(Probability)
Is it possib;e to calculate P va;ue for this data for ex?
7.891284
8.148193
7.749575
7.958188
7.887702
7.714877
8.141548
7.51845
8.27736
7.929853
7.92456
8.249126
7.989113
8.012573
8.351206 (2 Replies)
Discussion started by: stateperl
2 Replies
4. Shell Programming and Scripting
Hello,
I'm trying to create a shell script (#!/bin/sh) which should tell me the age of a file in minutes...
I have a process, which delivers me all 15 minutes a new file and I want to have a monitoring script, which sends me an email, if the present file is older than 20 minutes.
To do... (10 Replies)
Discussion started by: worm
10 Replies
5. Shell Programming and Scripting
Hi,
I have a file with more than 2,000 rows like this:
05/26/2011,1200,1500
I would like to create a awk shell script that calculate the price average of the second and third field each 5,10 and 20 rows or ask me for the values, starting at first row.
Finally compare the average value... (1 Reply)
Discussion started by: csierra
1 Replies
6. Shell Programming and Scripting
Long list of input file:
AGDRE1 0.1005449050
AGDRE1 2.1005443435
AGDRE1 1.2005449050
AGDRE1 5.1005487870
AASFV3 50.456304789
AASFV3 2.3659706549
AASFV3 6.3489807860
AASFV3 3.0089890148
RTRTRS 5.6546403546
.
.
Desired output file:
AGDRE1 8.5021829410
AASFV3 62.180245240... (2 Replies)
Discussion started by: perl_beginner
2 Replies
7. UNIX for Dummies Questions & Answers
Hi.
For an homework, I have to simulate some part of the PS function. By reading the doc I've been able to find most of it but I don't how I can get the %cpu for each PID.
I've read on Internet that I have to do:
(utime(t)-utim(t-1))/(cputime(t)-cputime(t-1))
where cputime is the sum of... (2 Replies)
Discussion started by: elnabo
2 Replies
8. UNIX for Dummies Questions & Answers
i have file input
abcedef|wert|13|03|10|04|23|A1|13|05|01|09|31
fsdasdf|ferg|12|04|25|21|21|A1|13|02|26|20|31
dfsfsad|gerg|12|04|25|21|21|A1|13|02|25|25|31
i expect the output
abcedef|wert|13|03|10|04|23|A1|13|05|01|09|31|9.516666667... (5 Replies)
Discussion started by: radius
5 Replies
9. Shell Programming and Scripting
Experts,
file1 : Want to find the difference of $3 field from next line's 3rd field,
The difference to be calculated from next lines 3rd field, to current lines lines 3rd field.
file1 :
Jun24_2013.06242013 3301244928 3133059904 167370640 95%
Jun25_1124.06252013 3301244928... (4 Replies)
Discussion started by: rveri
4 Replies
10. Shell Programming and Scripting
Hi
is there a way to calculate the progress when using the tar -cvf a folder say of 300Gb (4 Replies)
Discussion started by: fretagi
4 Replies
LEARN ABOUT CENTOS
pmunitsstr
PMUNITSSTR(3) Library Functions Manual PMUNITSSTR(3)
NAME
pmUnitsStr, pmUnitsStr_r - convert a performance metric's units into a string
C SYNOPSIS
#include <pcp/pmapi.h>
const char *pmUnitsStr(const pmUnits *pu);
char *pmUnitsStr_r(const pmUnits *pu, char *buf, int buflen);
cc ... -lpcp
DESCRIPTION
The encoding of a performance metric's dimensionality and scale uses a pmUnits structure; see pmLookupDesc(3).
As an aid to labeling graphs and tables, or for error messages, pmUnitsStr will take a dimension and scale specification as per pu, and
return the corresponding text string. The pmUnitsStr_r function does the same, but stores the result in a user-supplied buffer buf of
length buflen, which should have room for at least 60 bytes.
For example {1, -2, 0, PM_SPACE_MBYTE, PM_TIME_SEC, 0}, as the value of *pu gives the result string Mbyte / sec^2.
The string value result from pmUnitsStr is held in a single static buffer, so the returned value is only valid until the next call to pmU-
nitsStr.
If the ``count'' dimension is non-zero, and the ``count'' scale is not zero, then the text string will include a decimal scaling factor,
eg. count x 10^6.
As a special case, if all components of the dimension are zero, then the ``count'' scale is used to produce the text. If this scale is
zero the result is an empty string, otherwise the result is of the form x1 0^2.
NOTES
pmUnitsStr returns a pointer to a static buffer and hence is not thread-safe. Multi-threaded applications should use pmUnitsStr_r instead.
SEE ALSO
PMAPI(3), pmAtomStr(3), pmConvScale(3), pmExtractValue(3), pmLookupDesc(3), pmPrintValue(3) and pmTypeStr(3).
Performance Co-Pilot PCP PMUNITSSTR(3)