Can you perform mathematical equations in UNIX?


 
Thread Tools Search this Thread
Top Forums UNIX for Dummies Questions & Answers Can you perform mathematical equations in UNIX?
# 1  
Old 10-14-2007
Can you perform mathematical equations in UNIX?

Hello one and all,

I have a basic background in UNIX, but I was wondering if there is a way to perform simple mathematical equations (like multiplication, addition)? If so, is there a way to multiply values from a column by a value to produce a column with the answers? Smilie

I am working on a simple research project and in some data sets I have to get the the values of the velocity for a string of data...i.e.

data * (speed of light) = [desired answers]
5.7 * (299792458) = [1708817010.6]
6.8 = [2038588714.4]
7.3 = [2188484943.4]
5.1 = [1528941535.8]

Is there a simpler way to get my desired values besides find the values individually on my calculator? I would greatly appreciate any assistance.
# 2  
Old 10-14-2007
"bc" is a basic calculator, you can pipe some expressions into it and get results.

However with "tables" you end up being more a victim of the format of the table than the calculation.
# 3  
Old 10-15-2007
hm...well, as a victim of a table, is there a way to make calculations? do I need to make some sort of program?
# 4  
Old 10-15-2007
If you are ready to write some scripts then I cannot see why that cannot be done. If the combination of shell script + bc doesn't satisfy your requirements, you may consider languages such as Perl which gives you a more sophisticated environment if a more programmatic approach is desired.
# 5  
Old 10-15-2007
Hi.

The system "R" can be used for analysis and graphing. It is the free software version of the proprietary system "S" (Becker, Chambers, Wilks).

For me, the install was easy; I use Debian Linux, and it was in the repository.

Here is the brief (and cleaned up) copy of the session I had with your data:
Code:
Mon Oct 15 05:43:29 CDT 2007

Type 'q()' to quit R.

[Previously saved workspace restored]

> sol <- 299792458
> sol
[1] 299792458
> t <- c(5.7,6.8,7.3,5.1)
> t*sol
[1] 1708817011 2038588714 2188484943 1528941536
> q('yes')

For more information, visit The R Project for Statistical Computing

Best wishes ... cheers, drl
 
Login or Register to Ask a Question

Previous Thread | Next Thread

9 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

Should pick latest file within past 3 days using UNIX script and perform steps in message below.

Hi , Can anyone help me how do perform below requirement in unix. Step1:we will receive multiple files weekly with same name(as below) in a folder(In folder we will have other files also def.dat,ghf.dat) Filenames: 1) abc_20171204_052389.dat 2)abc_20171204_052428.dat DON'T modify... (23 Replies)
Discussion started by: sunnykamal59
23 Replies

2. Shell Programming and Scripting

awk script to perform an action similar to vlookup between two csv files in UNIX

Hi, I am new to awk/unix and am trying to put together an awk script to perform an action similar to vlookup between the two csv files. Here are the contents of the two files: File 1: Date,ParentID,Number,Area,Volume,Dimensions 2014-01-01,ABC,247,83430.33,857.84,8110.76... (9 Replies)
Discussion started by: Prit Siv
9 Replies

3. Shell Programming and Scripting

How To Perform Mathematical Operation Within If in awk?

Hi All, I am using an awk script as below: awk -F'|' 'BEGIN{OFS="|";} { if ($1==$3 && $3==$7 && $7==$13 && $2==$6 && $6==$11 && $15-$14+1==$11) print $0"|""TRUE"; else print $0"|""FALSE"; }' tempfile.txt In above script, all conditions are being checked except the one which is... (4 Replies)
Discussion started by: angshuman
4 Replies

4. Shell Programming and Scripting

UNIX shell script - cut specified line and perform loop

Guys, I have a requirement as below. consider,if i use df command, its getting the below output. file system kbytes used avail %used Mounted on /dev/sample/ 45765 40000 5765 50% / /dev/filesys/ 30000 20000 1000 80% /u .... .... Now i wanted to cut the /u... (11 Replies)
Discussion started by: AraR87
11 Replies

5. Shell Programming and Scripting

Unix Script -- Unable to perform division

I'm new to scripts, i wrote the below script to capture the percentage of FreeMemory available in Linux box. Output of UsedfreeMemory is displayed as '0'. I'm expecting the output like 0.89 (or) .89 --- ( 0.89 perferable) Anyone can help me on this pls. ... (3 Replies)
Discussion started by: murali1687
3 Replies

6. UNIX for Dummies Questions & Answers

Awk - Two equations?

I really know barely anything about awk and the like but I have a bit of code I need help with. The bash script is meant to get my usage numbers from my ISP and it does so perfectly. However I want to know how much I can use each day. So to do this I would need to divide its output by the number... (5 Replies)
Discussion started by: Light_
5 Replies

7. High Performance Computing

Differential Equations

I`m having a cluster with Rocks 5.2 distribution and I want to solve differential equations and I`m interested to know if are some programs already developed to do this. (3 Replies)
Discussion started by: rapo
3 Replies

8. UNIX for Dummies Questions & Answers

how can perform zip or unzip at unix console

how can perfrom zip or unzip for bulk of files at unix console can anybody tell that command (2 Replies)
Discussion started by: lmraochodisetti
2 Replies

9. Shell Programming and Scripting

How to perform comparision in unix

I am trying to perform a simple if/else check. if ; then mkdir /wdnet/oracletest else mkdir $CON_DIR fi I guess I don't understand the unix basics about comparisons. My scripts always executes the if, even though my CON_DIR variable is not blank. What am I doing... (5 Replies)
Discussion started by: artfuldodger
5 Replies
Login or Register to Ask a Question