Sponsored Content
Operating Systems Solaris How to perform addition of two numbers in shell scripting in Solaris-10 Post 302147197 by krevathi1912 on Monday 26th of November 2007 12:18:49 AM
Old 11-26-2007
Quote:
Originally Posted by Perderabo
We need to see the rest of the script to tell why that statement was unexpected.

Below is my script

#!/bin/bash
echo "Enter the start IP"
IFS="."
read s1 s2 s3 s4
echo "Enter the End IP"
IFS="."
read e1 e2 e3 e4
TOTAL=$(($e4 - $s4))
echo "Total is $TOTAL"


Any idea
 

10 More Discussions You Might Find Interesting

1. Shell Programming and Scripting

How to perform calculations using numbers greater than 2150000000.

Could someone tell me how to perform calculations using numbers greater than 2150000000 in Korn Shell? When I tried to do it it gave me the wrong answer. e.g. I have a ksh file with the contents below: --------------------------------- #!/bin/ksh SUM=`expr 2150000000 + 2` PRODUCT=`expr... (3 Replies)
Discussion started by: stevefox
3 Replies

2. Shell Programming and Scripting

Addition of numbers in unix

Hi I have a file with specified format . Hxxxxxxxyyyyyggggggguuuuuuuuuurrrrrrrrrrrrrrrrrrrrrrrr xxxxxxxxyyyyyggggggguuuuuuuuuurrrrrrrrrrrrrrrrrrrrrrrr xxxxxxxxyyyyyggggggguuuuuuuuuurrrrrrrrrrrrrrrrrrrrrrrr xxxxxxxxyyyyyggggggguuuuuuuuuurrrrrrrrrrrrrrrrrrrrrrrr... (3 Replies)
Discussion started by: asinha63
3 Replies

3. Shell Programming and Scripting

Addition of all the numbers in a single file

Hi All , Want to know the "sum" of all the digits in below file called "/sample" .Could some one please let me know the script either command . cat /sample 12 34 23 23 Best Regards, Chinni . (5 Replies)
Discussion started by: chinni-script
5 Replies

4. Shell Programming and Scripting

Addition of floating numbers

Hi, i want to add two decimal values to $ set a= 12.4 $ set b=3.6 $ w=`expr $a - $b` expr: non-numeric argument or is there any other method to do this mathematics operation. i need to use this into my script. (4 Replies)
Discussion started by: dear_abhi2007
4 Replies

5. Shell Programming and Scripting

Help with addition of 2 numbers that are read from a file

I am trying to add free and used memory (so that i can compute percentage used)of remote nodes using shell script. I use the openssh-server,expect tool and ssh script. 1)login.txt (info of nodes): ip1|username|password ip2|username|password . . . 3)sshlogin.sh #!/bin/bash ... (1 Reply)
Discussion started by: marmik1903
1 Replies

6. Shell Programming and Scripting

addition of both positive and negative numbers

Let, I have three numbers +00123.25 -00256.54 +00489.23 I need to sum up all those three numbers, after storing them in three variables (say var1, var2, var3). I used both expr and BC, but they didn't work for me. But, I am not able to sum up them, as I don't have any idea how to... (13 Replies)
Discussion started by: mady135
13 Replies

7. Shell Programming and Scripting

addition of two numbers

by the script, two files Q1 and Q2 will be generated on the system. Q1 will contain an integer number and Q2 also contain an integer number. i would like to add those numbers and put into new file. excerpt from my script 22 subcount=`echo $dir/Q$qid.txt` + `echo $dir/Q$qid.txt` 23 echo... (1 Reply)
Discussion started by: lookinginfo
1 Replies

8. Shell Programming and Scripting

Help with figuring division and addition based on column data and line numbers

I have a data file in the format of 1234 xxx 1234 xxx 1234 xxx 1234 xxxI want to be able to calculate the following - COLUMN1+((LINENUMBER-1)/365) The output needs to preserve the 2nd column - 1234 xxx 1234.00274 xxx 1234.00548 xxx What is the best way to do this? I am somewhat... (9 Replies)
Discussion started by: ncwxpanther
9 Replies

9. Shell Programming and Scripting

Help me to perform count & group by operation in shell scripting?

Hi All, I want to display the distinct values in the file and for each distinct value how may occurance or there. Test data: test1.dat 20121105 20121105 20121105 20121105 20121106 20121106 20121106 20121105 I need to display the output like Output (2 Replies)
Discussion started by: bbc17484
2 Replies

10. Shell Programming and Scripting

Find a matched pattern and perform comparison on numbers next to it

Hi, I have been trying to extract rows that match pattern "cov" with the value next to it to be > 3. The 'cov' pattern may appear either in $3 or $4 (if using ";" as field separator). Below is the example:- input file ... (7 Replies)
Discussion started by: bunny_merah19
7 Replies
SHTOOL-ECHO.TMP(1)					      GNU Portable Shell Tool						SHTOOL-ECHO.TMP(1)

NAME
shtool-echo - GNU shtool echo(1) extensional command SYNOPSIS
shtool echo [-n|--newline] [-e|--expand] string DESCRIPTION
shtool echo is an echo(1) style command which prints string to stdout and optionally provides special expansion constructs (terminal bold mode, environment details, date, etc) and newline control. The trick of this command is that it provides a portable -n option and hides the gory details needed to find out the environment details under option -e. OPTIONS
The following command line options are available. -n, --newline By default, output is written to stdout followed by a "newline" (ASCII character 0x0a). If option -n is used, this newline character is omitted. -e, --expand If option -e is used, string can contain special "%x" constructs which are expanded before the output is written. Currently the following constructs are recognized: %B switch terminal mode to bold display mode. %b switch terminal mode back to normal display mode. %u the current user name. %U the current user id (numerical). %g the current group name. %G the current group id (numerical). %h the current hostname (without any domain extension). %d the current domain name. %D the current day of the month. %M the current month (numerical). %m the current month name. %Y the current year. EXAMPLE
# shell script shtool echo -n -e "Enter your name [%B%u%b]: "; read name shtool echo -e "Your Email address might be %u@%h%d" shtool echo -e "The current date is %D-%m-%Y" HISTORY
The GNU shtool echo command was originally written by Ralf S. Engelschall <rse@engelschall.com> in 1998 for Website META Language (WML) under the name buildinfo. It was later taken over into GNU shtool. SEE ALSO
shtool(1), echo(1). 18-Jul-2008 shtool 2.0.8 SHTOOL-ECHO.TMP(1)
All times are GMT -4. The time now is 10:34 PM.
Unix & Linux Forums Content Copyright 1993-2022. All Rights Reserved.
Privacy Policy