Sponsored Content
Top Forums Shell Programming and Scripting Which is the best way/command to do mathematics in UNIX scripting? Post 302403985 by methyl on Monday 15th of March 2010 08:27:03 AM
Old 03-15-2010
Quote:
read lol
read lil
echo "scale=2; $lol - $lil" | bc

A hunch. How did you execute these three lines?

If you type them one-by-one at the command prompt answering each "read" before typing the next command ... they should work.

If you put them in a shell script and execute the script ... they should work.

If you cut/paste all three lines onto the command line they will fail. This is because the second line becomes the input to the first line meaning that $lol contains the string "read lil" which in turn makes the echo contain rubbish to pass to "bc".
 

8 More Discussions You Might Find Interesting

1. UNIX for Dummies Questions & Answers

mathematics operations in unix

Hello guys! Can say me anybody about operatios with unix, I don't to make operations, only inside in a variable, like this #y=4 #x=2 #let z=$y-$x #echo $z # 2 but I can't to make mathematical operations with decimal like this #y=3.2 #x=1.5 #let z=$y-$x #echo $z # 3 this... (2 Replies)
Discussion started by: cesar720213
2 Replies

2. UNIX for Dummies Questions & Answers

mathematics in shell script

Hi Friends, I am new to shell scripting and a trying to work this out. I have a variable called $number. The value in this variable is 10 I want to display $number - 2 in a mail. The result would be 8 eg. mail -s 'subject' user <<eof the result of your calculation is $number - 2... (2 Replies)
Discussion started by: sureshy
2 Replies

3. Shell Programming and Scripting

difference between AIX shell scripting and Unix shell scripting.

please give the difference between AIX shell scripting and Unix shell scripting. (2 Replies)
Discussion started by: haroonec
2 Replies

4. Shell Programming and Scripting

hell & mathematics

I've been able to generate output based on the code scarfake provided me (thanks again man). A little background so everyone more or less knows whats going on: I needed code that would propagate a database with 100,000 entries, for capacity testing purposes, something like a stress test. ... (5 Replies)
Discussion started by: ogoy
5 Replies

5. Shell Programming and Scripting

recommend book for unix command/ shell scripting

Hi, i wish to learn unix commands and shell scripting. platform is solaris. but i am focused more on handy unix commands than system administration. which books do you recommend? (1 Reply)
Discussion started by: nurulamin862
1 Replies

6. UNIX for Dummies Questions & Answers

Unix Shell Scripting( Calling from Unix to PLSQL)

Hello Experts, I have the following questions to be discussed here at this esteemed discussion forum. I have two Excel sheets which contain Unix Commands llike creating directory the structure/ftp/Copy/Zip etc to basically create an environment. I need help in understanding some of... (1 Reply)
Discussion started by: faizsaadq
1 Replies

7. Shell Programming and Scripting

If else condition inside for loop of awk command in UNIX shell scripting

Hi , Please excuse me for opening a new thread i am unable to find out the syntax error in my if else condition inside for loop in awk command , my actual aim is to print formatted html td tag when if condition (True) having string as "failed", could anyone please advise what is the right... (2 Replies)
Discussion started by: karthikram
2 Replies

8. What is on Your Mind?

Forum Trivial Pursuit - New Computer Science and Mathematics Trivia for UNIX.com

I have added a new experimental "Computer Science and Mathematics Trivia - True or False" section in the discussions, currently under the tags box. In the future, I plan to Expand this feature to add more trivia categories from math, science and technology. Keep track of correct and... (20 Replies)
Discussion started by: Neo
20 Replies
Rscript(1)								FSF								Rscript(1)

NAME
Rscript - front end for scripting with R SYNOPSIS
Rscript [--options] [-e expr] file [args] DESCRIPTION
A binary front-end to R, for use in scripting applications. expr An optional expression to be evaluated, used in place of expr. file Input file of R expressions args Optional further arguments to be processed by commandArgs in the R interpreter. OPTIONS
--options accepted are --help Print usage and exit --version Print version and exit --verbose Print information on progress --default-packages=list Where 'list' is a comma-separated set of package names, or 'NULL' and also options to R (in addition to --slave --no-restore), such as --save Do save workspace at the end of the session --no-environ Don't read the site and user environment files --no-site-file Don't read the site-wide Rprofile --no-init-file Don't read the user R profile --restore Do restore previously saved objects at startup --vanilla Combine --no-save, --no-restore, --no-site-file --no-init-file and --no-environ SEE ALSO
R(1) R scripting April 2007 Rscript(1)
All times are GMT -4. The time now is 05:46 AM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy