10 More Discussions You Might Find Interesting
1. UNIX for Dummies Questions & Answers
I have a function that outputs 3 lines for each result and I want to know how many results there are.
so for example
function | wc -l
24
but I want to see the result 8.
so is there a easy way to divide the result? (5 Replies)
Discussion started by: yatici
5 Replies
2. UNIX for Dummies Questions & Answers
hi,
The below commands result only the whole number(not giving the decimal values).
pandeeswaran@ubuntu:~$ echo 1,2,3,4|sed 's/,/\//g'|bc
0
pandeeswaran@ubuntu:~$ echo 1000,2,3|sed 's/,/\//g'|bc
166
How to make it to return the decimal values?
Thanks (5 Replies)
Discussion started by: pandeesh
5 Replies
3. Shell Programming and Scripting
I want to perform the below division operation in shell script and round the value.
val1=6000
val2=5000
res=val1/val2 ----> 1.2---> Round to 2
Please help. (3 Replies)
Discussion started by: vel4ever
3 Replies
4. UNIX for Advanced & Expert Users
I received error "awk: division by zero" while executing the following statement.
SunOS 5.10 Generic_142900-15 sun4us sparc FJSV,GPUZC-M
echo 8 | awk 'END {printf ("%d\n",NR/$1 + 0.5);}' file1.lst
awk: division by zero
Can someone provide solution?
Thanks
Please use code... (11 Replies)
Discussion started by: kumar77
11 Replies
5. Shell Programming and Scripting
Hello,
I am searching for a way to calculate for example 10/100 within a shellscript and the result should be 0.1 and not just 0.
Every alternative i tried just results 0
Thank you in advance
2retti (6 Replies)
Discussion started by: 2retti
6 Replies
6. UNIX for Dummies Questions & Answers
Here's a program and its pretty simple .It requires file handling and some calculations but on running it I am not getting the required result.It seems that the code outside the file read's outer while loop is not executing e.g the print statement is not being printed.Plz Help!
#include<stdio.h>... (1 Reply)
Discussion started by: headrush
1 Replies
7. Shell Programming and Scripting
i have a script that is doing the following:
awk 'BEGIN {FS=","} ; {printf("%.10f",($5 - $2)/(3 * $3))}' data > test
now some records in $3 contain zeroes. i don't want to remove those records. is it possible to check for division by zero and then write a "N/A" for that record in the o/p... (2 Replies)
Discussion started by: npatwardhan
2 Replies
8. UNIX for Dummies Questions & Answers
hi
I am having two variables namely a=7 & b=8. I have to subtract these two variables. I am using the command
c=`expr $a / $b`
When I check the value of c, it comes out to be zero.
Please help.
Regards
Rochit (9 Replies)
Discussion started by: rochitsharma
9 Replies
9. Filesystems, Disks and Memory
I have a doubt with an error message, and i want to be sure if this is a normal situation or not.
Situation: I was formating and installing a SCSI 36Gb HD with UNIX SCO 5.05, the problem happens when is making the division and filesystem on disk 1, and the message error is "Exit value 139... (1 Reply)
Discussion started by: jav_v
1 Replies
10. Shell Programming and Scripting
Does anyone have a simple way of doing floating point ("fp") division? For example, if I divide 3 by 5, I can get 0.6. The built-in calc (`bc`) will perform fp multiplication, but not division, at least not straight-up (i.e., starting bc and just typing in 3/5).
I am trying to do this using... (1 Reply)
Discussion started by: gsatch
1 Replies