Questions tagged [arithmetic]

This tag is meant for everything that has to do with mathematical operations. So if you want to ask a question about doing calculations in `awk`, or if you have a question about `bc`, this is the right tag to use.

I have this logic in a ksh script on AIX 6.1 and it works fine.
integer loop_count=0
integer sleep_interval=5
integer alarm_interval=60
if (( $loop_count*$sleep_interval%$alarm_interval -eq 0 ))
then ...

Sometimes I need to run some math operations. I know I can use bc or echo $(( 6/2 )). I have created my own function for bc to read input. But sometimes it takes a long time to type: _bc "6/2". So I ...

How would I create a bash script that the user can use to sum any amount of command line arguments, but it will also ignore incompatible arguments? For example, say my script is called sum:
sum 10 -...

i have two files,the first file is written numbers for example 123,and the second file is the same and i want to sum or divide file_one plus file_Two = 123 + 123 result=246 i want to make arithmetic ...

I need to perform an arithmetic operation inside a bash loop as explained below
CYCLE?=3
COUNT=1
download_when_ready: ## Will try the download operations many times till it succeeds or it reaches 10 ...

I am writing a script which should listen on a specific port and once somebody connects to it via that port (through telnet), it should ask for 2 numbers and return their sum. Like when I type telnet [...

I have written a script to ssh remote hosts, execute commands, save output to files, and examine outputs. But it always exit silently at line (( success++ )) when iterate first item in array workers. ...

I was surprised to read this in the Bash manual, describing Arithmetic Evaluation:
Within an expression, shell variables may also be referenced by name without using the parameter expansion syntax.
...

When I trying to install a software license server which is a shell script, I have an error and really don't know the way out. I cannot find any error in the script. Hope anyone can give me some help.
...

I am very new to Linux and am taking a course in it. Very excited to learn more. I am working on a script that asks user for two numbers, then asks whether user wants to add or subtract. I failed the ...

Okay, so I been trying to figure this problem for a while and I'm coming up with errors left and right. This is my first time trying to learn the basics. So any advice would be helpful!
Problem: I'm ...

I seem to recall from comments on this site that the contents of arithmetic expansion may be word split, but I can't find the comment again.
Consider the following code:
printf '%d\n' "$(($(sed -n '/...